include<bits/stdc++.h>

using namespace std;

typedef long long ll; typedef double dbl;

define fr(x,a,b) for(ll x=a;x<b;x++)

define PB push_back

define MP make_pair

define mod 1000000007

define gmax LLONG_MAX

define gmin LLONG_MIN

define INF 2e9

define N 100001

define MAX(a,b,c) max(max(a,b),c)

define MIN(a,b,c) min(min(a,b),c)

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; }