#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
const int MOD=998244353;
const int INF=1e18;
void io(string s1="input.txt",string s2="output.txt"){freopen(s1.c_str(), "r", stdin);freopen(s2.c_str(), "w", stdout);}


signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;
    n=(1LL<<n);
    vi v(n);
    map<int,int> id;
    for(int i=0;i<n;i++){
        cin>>v[i];
        id[v[i]]=i+1;
    }

    while(v.size()!=2){
        vi tmp;
        for(int i=0;i<v.size();i+=2){
            tmp.push_back(max(v[i],v[i+1]));
        }
        v=tmp;
    }

    cout<<id[min(v[0],v[1])];
}
#include <bits/stdc++.h>

using namespace std;

int a, b, c, d, x, y;


int main(){
    cin >> a >> b >> c >> d ;

    x = max({a, b});
    y = min({c, d}) ;
   cout << x - y;
}
