def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end
require "prime"
def jo(n,d)
  return 1 if(n == 0)
  return d if(n == 1)
  return (jo(n/2,d)**2 * jo(n-n/2*2,d))%@r
end

@r = 10**9 + 7
@t = na(10**6)
def kaijo2(l,m,n)
  max = [l,m].max
  min = [l,m].min
  ans = 1
  ans2 = 1
  ind2 = 0
  (1..n).each do |i|
    if(i > max)
      ans *= i
    end
    if i <= min
      ans2 *= i
    end
    ans %= @r
    ans2 %= @r
  end
  return (ans * jo(@r-2,ans2))%@r
end

x,y = inp
kaisu1 = nil
kaisu2 = nil

eve_f = 0
if(x%2 == 1)
  x -= 1
  y -= 2
  eve_f = 1
end


#全部2からの差
max_sa = 2*x - y

if(max_sa % 3 != 0)
  puts 0
  exit
end

kaisu2 = max_sa/3
kaisu1 = (x-kaisu2*2)
if(max_sa < 0)
      puts 0
      exit
end
if(kaisu1 < -1)
      puts 0
      exit
end
p kaijo2(kaisu1+eve_f,kaisu2,kaisu1+kaisu2+eve_f)
