#include<bits/stdc++.h>
using namespace std;
int n,a,b,c; bool x,y,z;
int main(){
scanf("%d%d%d%d",&n,&a,&b,&c);
if(c<4) x=1;
if(c<6) y=1;
if(c<10) z=1;
if(x) printf("%d",min(a,min(b,c)));
else if(y) printf("%d",min(b,c));
else printf("%d",c);
return 0;
}