#include <stdio.h>
#include <iostream>
using namespace std;
/*
        8
      /      \
     /        \
    4          12
   / \            /  \
  2   6      10   14
 / \     / \    / \     /  \
1  3 5  7 9 11 13 15
          
*/
int zhongjianzhi(int m ,int n,int curroot,int k){
  if(curroot == (m + n)/ 2)  return curroot;
  if(m > curroot && n < curroot) return curroot;
  else if (m> curroot && n > curroot){
    curroot = (curroot + (1<<k)) /2;
    zhongjianzhi(m,n,curroot,k);
  }
  else {
    curroot = (curroot + 0)/2;
    zhongjianzhi(m,n,curroot,k);
  }
}

int main(){
  int k,a,b,c;
  cin >> k;
  cin >>  a >>  b >>  c;
   int num = 0;
   int maxx = max(max(a,b),c);
   int minn = min(min(a,b),c);
   int curroot = 1<<(k-1);
   num = zhongjianzhi(maxx,minn,curroot,k);
   cout << num << endl;
   return 0;
}