import scala.collection.mutable

object Main extends App {
  val max = 7368791
  scala.io.Source.stdin.getLines
    .map(_.split(" ").map(_.toInt))
    .map { case Array(m, n) => (m, n) }
    .filter { case (m, _) => m != 0 }
    .map { case (m, n) => f(m, n) }
    .foreach(println)

  def f(m: Int, _n: Int): Int = {
    val set = mutable.BitSet()
    var n = _n
    set ++= m to max
    var i = m
    while (true) {
      if (set.contains(i)) {
        if (n == 0) return i
        set --= i to max by i
        n -= 1
      }
      i += 1
    }
    0
  }
}

