#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int m = 1;
    while (n != 0) {
        m *= 2;
        --n;
    }

    int a, b;
    a = 0; b = 0;
    for (int i = 1; i <= m / 2; ++i) {
        int c;
        cin >> c;
        if (b < c) {
            a = i;
            b = c;
        }
    }
    int e, f;
    e = 0; f = 0;
    for (int i = 1; i <= m / 2; ++i) {
        int c;
        cin >> c;
        if (f < c) {
            e = i + m / 2;
            f = c;
        }
    }

    if (b < f) {
        cout << a << endl;
    }
    else {
        cout << e << endl;
    }

    return 0;
}
#include <bits/stdc++.h>
using namespace std;
template<class T>void chmin(T& a,T b){
    if(a>b){
        a=b;
    }
}
typedef std::pair<int,int> p;

#define rep(i,n) for(int i=0;i<n;++i)

int main(){
  const int INF=1001001001;
  int N;
  cin>>N;
  int k=1<<(N-1);
  vector<int> a(k),b(k);
  rep(i,k)cin>>a[i];
  rep(i,k)cin>>b[i];
  
  
  vector<int>::iterator iter_c=max_element(a.begin(),a.end());
  vector<int>::iterator iter_d=max_element(b.begin(),b.end());

  size_t index_c=distance(a.begin(),iter_c);
  size_t index_d=distance(b.begin(),iter_d);

  if(*iter_c<*iter_d)cout<<index_c+1<<endl;
  else cout<<k+index_d+1<<endl;

  

}