#include <bits/stdc++.h>
using namespace std;
/* ========== defines =========*/
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/* ========== defines =========*/
int main()
{
    IOS;
    int t;
    cin >> t;
    while (t--)
    {
        int n, x, up = 0;
        cin >> n;
        for (int i = 0; i < n; ++i)
        {
            cin >> x;
            if (x != 2)
                up++;
        }
        cout << up << endl;
    }
}