"use strict"

const arg_str = require('fs').readFileSync('/dev/stdin', 'UTF-8')
const args = arg_str.split(' ')
const X = args[0]
const Y = args[1]

let dp = []
dp.push({x:1,y:2,v:1})
dp.push({x:2,y:1,v:1})

for(let i=0;i<=X;i++){
    for(let j=0;j<=Y;j++){
        const current_dp = dp.find(x => x.x == i && x.y == j)
        if(!current_dp){
            let tmp_1 = 0
            if(i - 1 >= 0 && j - 2 >= 0){
                const tmp_dp_1 = dp.find(x => x.x == i - 1 && x.y == j - 2)
                if(tmp_dp_1){
                  tmp_1 = tmp_dp_1.v
                }
            }
            let tmp_2 = 0
            if(i - 1 >= 0 && j - 2 >= 0){
                const tmp_dp_2 = dp.find(x => x.x == i - 2 && x.y == j - 1)
                if(tmp_dp_2){
                  tmp_2 = tmp_dp_2.v
                }
            }
            dp.push({x:i,y:j,v:tmp_1 + tmp_2})
        }
    }
}

const result = dp.find(x => x.x == X && x.y == Y)
if(result){
    console.log(result.v % 1000000007)
}else{
    console.log(0)
}

