arr = Array.new(1000, false)
n = gets.to_i
sequence = ""
while line = gets
    sequence += line.chomp.split.join
end
0.upto(sequence.length - 1){|i|
    arr[sequence[i, 1].to_i] = true
    arr[sequence[i, 2].to_i] = true
    arr[sequence[i, 3].to_i] = true
}
puts arr.find_index{|x| x == false}
