LuckyFour

You are given a list of T integers, for each of them you have to calculate the number of occurrences of the digit 4 in the decimal representation.

Input

The first line of input consists of a single integer T*, denoting the number of integers in the list.*

Then, there are T lines, each of them containing a single integer from the list.

Output

Output T lines. Each of these lines should contain the number of occurrences of the digit 4 in the respective integer from the list.

Constraints

  • 1 T 105

  • (Subtask 1): 0 ≤ Numbers from the list ≤ 9 - 33 points.

  • (Subtask 2): 0 ≤ Numbers from the list ≤ 109 - 67 points.

Sample 1:

Input

5
3484424
300
4563
14
99

Output

4
0
1
1
0

Explanation:

There are four 4s in the 3484424, no 4s in 300, one 4s in 4563

Solution:

Language: Java


import java.util.*;
import java.lang.*;
import java.io.*;

class navnath
{
    public static void main (String[] args) throws java.lang.Exception
    {
    try {
        InputStreamReader r=new InputStreamReader(System.in);    
        BufferedReader br=new BufferedReader(r);    
        String t = br.readLine();

        for(int i=0; i<Integer.parseInt(t); i++)
       {
           String n = br.readLine();
            int counter = 0;

            for(int j=0; j<n.length(); j++)
           {
                if(n.charAt(j) == '4')
                {
                    counter++;
                }
            }
            System.out.println(counter);
        }

    } catch(Exception e) 
    {
        return;
    }
    }
}