import scala.collection.mutable._
import scala.math._
import scala.util.control.TailCalls._
object Main {
  private val memo: HashMap[(Int, Int), Int] = new HashMap
  def calculate(x: Int, y: Int): TailRec[Int] = {
    memo.get((x, y)) match {
      case Some(v) =>
        done(v)
      case None =>
        (x, y) match {
          case (_, _) if x <= 1 && y <= 1 =>
            memo((x, y)) = 0
            done(0)
          case (2, 1) | (1, 2) =>
            memo((x, y)) = 1
            done(1)
          case (_, _) =>
            for {
              m <- tailcall(calculate(x - 1, y - 2))
              n <- tailcall(calculate(x - 2, y - 1))
              val k = (memo((x, y)) = m + n)
            } yield {
              m + n
            }
        }
    }
  }
  def main(args: Array[String]): Unit = {
    val line = Console.in.readLine()
    val Array(tx, ty) = line.split(" ")
    val X = tx.toInt
    val Y = ty.toInt
    val count = calculate(X, Y).result
    val result = count % (pow(10, 9).toInt + 7)
    println(count)
    print(result)
  }
}