object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val S, T = sc.next
    val A, B = sc.nextInt
    val U = sc.next

    var ans = 0;

    if (S == U) ans = A - 1
    else ans = B - 1
    print(ans)
  }
}