/*
 * Author: Moon-light
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define lowbit(x) ((x)&(-x))
#define sz(x) ((int)x.size())
#define fr(x) freopen(x,'r',stdin)
#define fw(x) freopen(x,'w',stdout)
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) begin(a),end(a)
#define bitcnt(x) (__builtin_popcountll(x))
#define rep(i,a,b) for(int i = (a);i<=(b); ++i)
#define per(i,a,b) for(int i = (a);i>=(b); --i)
typedef long long LL;
typedef pair<int,int> PII;  
typedef pair<LL,LL> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VB;
typedef double db;

template <class T> void clear(T& a) { T().swap(a);}
template <class T,class S>
inline bool upmin(T& a,const S&b){ return a>b ? a=b,1:0;}
template <class T,class S>
inline bool upmax(T&a, const S&b){ return a<b? a=b,1:0;}

//fast read(improved by fread)
char buf[1<<21],*p1=buf,*p2=buf;
inline int getc(){
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
}
inline int redi() {
    int ret = 0,f = 0;char ch = getc();
    while (!isdigit (ch)) {
        if (ch == '-') f = 1;
        ch = getc();
    }
    while (isdigit (ch)) {
        ret = ret * 10 + ch - 48;
        ch = getc();
    }
    return f?-ret:ret;
}

//global variable
const int N = 1;
const int mod = 1e9+7;
vector<PII> a;
int n;
//functions
LL qmi(LL a,LL k,LL mod){
    LL res = 1;
    while(k){
        if(k&1) res = res*a%mod;
        k >>= 1;
        a = a*a%mod;
    }
    return mod;
}
int gcd(int a,int b) {
    return b==0? a:gcd(b,a%b);
}
//


//code from here! Come on! Have a pleasant experience~
int main()
{
    IO;
    cin>>n;

    int x;
    n = pow(2,n);
    rep(i,1,n){
        cin>>x;
        a.push_back({x,i});
    }
    vector<PII> t = a;
    

    while(t.size()>2){
        vector<PII> b;
        for(int i = 0; i<n-1; i+=2){
            if(t[i].first > t[i+1].first){
                b.push_back(t[i]);
            }else{
                b.push_back(t[i+1]);
            }
            // cout<<t[i].first<<" "<<t[i+1].first<<endl;
        }
        t = b;
        n = t.size();
    }

    if(t[0].first > t[1].first){
        cout<<t[1].second<<endl;
    }else{
        cout<<t[0].second<<endl;
    }
    return 0;
}
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define sz(x)                 (int)(x).size()
#define all(x)                (x).begin(), (x).end()
#define tr(x, it)             for(auto (it) = (x).begin();it != (x).end();it++)
#define fo(i, k, n)           for(int i = (k);i < (n);i++)
#define Fo(i, k, n)           for(int i = (k);i >= (n);i--)
#define el                    "\n"
#define ff                    first
#define ss                    second
#define ll                    long long
#define pb                    push_back
#define mp                    make_pair
#define pii                   pair<int, int>
#define vi                    vector<int>
#define mii                   map<int, int>
//#define pqb                   priority_queue<int>
//#define pqs                   priority_queue<int, vi, greater<int>>
//#define pc(x)                 putchar(x);
//#define setbits(x)            __builtin_popcountll(x)
//#define zrobits(x)            __builtin_ctzll(x)
#define mod                   1000000007
#define inf                   1e18
//#define ps(x, y)              fixed<<setprecision(y)<<x
//#define mk(arr, n, type)      type *arr = new type[n];
//#define w(x)                  int x; cin>>x; while(x--)
#define deb(x)                cout<<#x<< " = "<< (x)<<"\n";

void solve(){
	int n, x;
	cin>>n>>x;
	int ar[n];
	fo(i, 0, n){
		cin>>ar[i];
	}
	fo(i, 0, n){
		if(ar[i] != x) cout<<ar[i]<<" ";
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;
	// cin>>t;	
	while(t--){
		solve();
		cout<<el;
	}
	return 0;
}
	// int n, m;
	// cin>>n>>m;
	// int a[n], b[n], c[m];
	// fo(i, 0, n) cin>>a[i];
	// fo(i, 0, n) cin>>b[i];
	// fo(i, 0, m) cin>>c[i];
	// int idxa = -1, idxc = -1, i = m-1;
	// bool bb = false;
	// fo(j, 0, n){
	// 	if(c[i]==b[j] && b[j]!=a[j]){
	// 		idxa = j;
	// 		idxc = i;
	// 		bb = true;
	// 		// deb(i)
	// 		// deb(j)
	// 		break;
	// 	}
	// }
	// if(!bb){
	// 	fo(j, 0, n){
	// 		if(c[i]==b[j]){
	// 			idxa = j;
	// 			idxc = i;
	// 			// deb(i)
	// 			// deb(j)
	// 			bb = true;
	// 			break;
	// 		}
	// 	}
	// }
	
	// if(!bb){
	// 	cout<<"NO";
	// 	return;
	// }
	// vector<int> v;
	// fo(i, 0, m){
	// 	if(i == idxc) continue;
	// 	bool bbb = false;
	// 	fo(j, 0, n){
	// 		if(j == idxa) continue;
	// 		if(c[i] == b[j] && b[j] != a[j]){
	// 			v.pb(j+1);
	// 			a[j] = c[i];
	// 			bbb = true;
	// 			break;
	// 		}
	// 	}
	// 	if(!bbb){
	// 		a[idxa] = c[i];
	// 		v.pb(idxa+1);
	// 	}
	// }
	// a[idxa] = c[idxc];
	// v.pb(idxa+1);
	// fo(i, 0, n){
	// 	if(a[i] != b[i]){
	// 		cout<<"NO";
	// 		return;
	// 	}
	// }
	// cout<<"YES"<<el;
	// 