lucky four codechef
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t,number,count,rem;
std::cin >> t;
for (int i = 0; i < t; i++) {
cin >> number;
while(number != 0){
rem = number % 10;
if (rem == 4){
count++;
}
number /= 10;
}
std::cout << count << std::endl;
count = 0;
}
return 0;
}