#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int k,a,b,c;
cin>>k>>a>>b>>c;
int i = 1,j = pow(2,k)-1;
int mid;
while(true)
{
mid = (i + j) / 2;
if(a < mid && b < mid && c <
mid)
{
j = mid - 1;
continue;
}
if(a > mid && b > mid && c >
mid)
{
i = mid + 1;
continue;
}
break;
}
cout<<mid<<endl;
return 0;
}