#include using namespace std; int main() { int B[10]; for (int i = 1; i < 10; i++) { cin >> B[i]; if (B[i] != i) { cout << B[i]-1 << endl; break; } if (B[i] == 9) { cout << B[i] + 1 << endl; } } return 0; }