// C - To Infinity
// https://abc106.contest.atcoder.jp/tasks/abc106_c

import scala.io.StdIn.readLine

object Main extends App {

  val s: Array[Char] = readLine.toCharArray
  val k: String = readLine

  val num: Char =
  if (s(0) != '1') {
    s(0)
  } else {
    if (k == "1") '1'
    else s(1)
  }

  println(num)

}