import scala.annotation.tailrec
import scala.io.StdIn._
object Main extends App {

  solve()
  @tailrec def solve(): Unit = {
    val Array(m, n) = readLine.trim.split(' ').map(_.toInt)
    if (m == 0 && n == 0) return
    val memo = Array.fill(7368792){false}
    var current = m
    for (_ ← 0 until n) {
      while (memo(current)) {
        current += 1
      }
      for (j ← current until memo.length by current) {
        memo(j) = true
      }
    }
    while (memo(current)) {
      current += 1
    }
    println(current)
    solve()
  }
}
