import sequtils,strutils

var b = stdin.readLine.split.map parseInt
var n = 0
for (i,j) in b.zip (1..9).toSeq:
  if i == j: n = j
echo n + 1