using namespace std;
typedef long long ll; typedef double dbl;
int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll n; cin>>n;
string s; ll f[3]={0}; fr(i,0,n){ cin>>s; if(s[0]=='1' && s[2]=='4') f[0]++; else if(s[0]=='1' && s[2]=='2') f[1]++; else f[2]++; }
//cout<<f[0]<<" "<<f[1]<<" "<<f[2]<<"\n";
ll d,cnt=1;
// combining 1(1/4) + 1(3/4) = 1 d=min(f[0],f[2]); cnt+=d; f[0]-=d; f[2]-=d;
//cout<<f[0]<<" "<<f[1]<<" "<<f[2]<<"\n";
// combining 2(1/4) + 1(1/2) = 1 d=min(f[0]/2,f[1]); cnt+=d; f[0]-=d*2; f[1]-=d;
//cout<<f[0]<<" "<<f[1]<<" "<<f[2]<<"\n";
// combining 4*(1/4) = 1 cnt+=f[0]/4; f[0]=f[0]%4;
//cout<<f[0]<<" "<<f[1]<<" "<<f[2]<<"\n";
// combining 2*(1/2) = 1 cnt+=f[1]/2; f[1]=f[1]%2;
//cout<<f[0]<<" "<<f[1]<<" "<<f[2]<<"\n";
// combining rest of the left slices cnt+=(f[0]+f[1]+f[2]);
cout<<cnt;
return 0; }