      MODULE modCombModule
        !nCk mod mo
        !n,k <= 10**5
        INTEGER(16),PARAMETER :: mo = 10**9+7
        INTEGER(16),PARAMETER :: ma = 10**7
        INTEGER(16) :: f(0:ma) = 0
        private :: mo,ma,f
        private :: initializeF, inv
        
        contains
        
        !private
        SUBROUTINE initializeF()
          implicit none
          INTEGER(16) :: i
          
          f(0) = 1
          DO i = 1,ma
            f(i) = mod( f(i-1)*i,mo )
          END DO
        END SUBROUTINE initializeF
        
        !private
        FUNCTION inv( in ) RESULT( out )
          implicit none
          INTEGER(16),INTENT(IN) :: in
          INTEGER(16) :: out
          INTEGER(16) :: k, y
          
          out = 1
          k   = mo-2
          y   = in
          DO while( k>0 )
            if( and(k,1)==1 ) out = mod(out*y,mo)
            y = mod( y*y,mo )
            k = rshift( k,1 )
          END DO
        END FUNCTION inv
        
        !public
        FUNCTION modComb( n,k ) RESULT( r )
          implicit none
          INTEGER(16),INTENT(IN) :: n,k
          INTEGER(16) :: r
          INTEGER(16) :: a,b,c,bc
          
          CALL initializeF()
          
          a = f(n)   ! n!
          b = f(n-k) ! (n-k)!
          c = f(k)   ! k!
          
          bc = mod( (b*c),mo )
          r  = mod( a*inv(bc),mo )
        END FUNCTION
      END MODULE modCombModule
      
      
      
      program knight
      USE modCombModule
      implicit none
      integer(16) :: x,y,ans
      integer(16) :: m,n
      
      read*,x,y
      
      
      if( mod(x+y,3)/=0 ) goto 100
      
      !(x,y)
      !(1,2) : n
      !(2,1) : m
      m = (2_16*x-y) / 3_16
      n = (2_16*y-x) / 3_16
      
      if( m<0 ) goto 100
      if( n<0 ) goto 100
      
      
      ans = modComb( m+n,m )
      print*,ans
      RETURN
      
 100  print*,0
      RETURN
      
      end program
      