EGYPIZZA

Abotrika is having a party because his team won the african cup so he is inviting his friends to eat some pizza. Unfortunately, Abotrika's friends can't eat an entire pizza but all of them know exactly how much pizza they can eat and insist on getting the exact amount of pizza but Abotrika eats one complete pizza and all of them wants his amount of pizza in one slice.

Their requests break down to three different pizza slices-either one quarter or a half or three quarters of pizza. write a program that will help Abotrika to find out what is the minimal number of pizzas he has to order so that everyone gets exact amount of pizza they want.

Input

First line contains an integer N, 0<=N<=10000, number of friends. In each of next N lines there is amount of pizza that each of Abotrika's friends wants to eat,that is the fraction 1/4, 1/2 or 3/4.

Output

In the first and only line you should write the minimal number of pizzas Abotrika has order don't forget to order one complete pizza for Abotrika

Example

Input:
3
1/2
3/4
3/4

Output:
4

Input:
5
1/2
3/4
1/2
1/4
1/4

Output:
4


#include <iostream>
#include <string>

using namespace std;

int main() {  
    int N;
    cin >> N;
    long long a = 1,
              q = 0,
              h = 0,
              t = 0;
    for (;N--;) {
        string s;
        cin >> s;
        if (s == "1/2") {
            ++h;
        } else if (s == "3/4") {
            ++t;
        } else {
            ++q;
        }
    }
    a += h / 2;
    a += (h % 2);
    if (h % 2 == 1) {
        q -= 2;
    }
    if (t >= q) {
        a += t;
    } else {
        a += t;
        q -= t;
        a += q/4;
        a += (q % 4 > 0 ? 1 : 0);
    }
    cout << a << "\n";
    return 0;
}