/*
        ________   ________    _________   ____________;_
       - ______ \ - ______ \ / _____   / /.  .  ._______/
      / /     / // /     / //_/     / / / ___   /
     / /     / // /     / /       .-'/ /_/|_/,-'
    / /     / // /     / /     .-'.-'
   / /     / // /     / /     / /
  / /     / // /     / /     / /
 / /_____/ // /_____/ /     / /
 \________- \________-     /_/
*/

/* This code belongs to overlord 007bond007
solution for: a
Tried on: 12 - 04 - 2021 */
#include<bits/stdc++.h>
using namespace std;

void solve() {

    int n = 0;
    cin >> n;
    long long ans = 0;
    for(int i = 0; i < n; i++) {
        int temp = 0;
        cin >> temp;
        if(temp != 2) ans++;
    }
    cout << ans << endl;
    
    
}

int main() {


#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 0;
    cin >> t;
    while(t--) {
        solve();
    }




    return 0;
}