#include<bits/stdc++.h>

using namespace std;
int n, k;
int n1, n2, n3, n4, n5;
int main(){
        cin >> n >> k;
    cin >> n1 >> n2;

if(n == 2){
if(n1==k){
    cout << n2 << endl;
}
if(n2==k){
    cout << n1 << endl;
}
}
if(n == 5){
    cin >> n3 >> n4 >> n5;
    if(k == n5){
        cout << n1 << endl;
    }else
    if(k == n4){
        cout << n5 << endl;
    }else
    if(k == n3){
        cout << n4 << endl;
    }else
    if(k == n2){
        cout << n3 << endl;
    }else
    if(k == n1){
        cout << n2 << endl;
    }
}

return 0;

}