**Physical Address**

304 North Cardinal St.

Dorchester Center, MA 02124

Karan likes the number **4** very much.

Impressed by the power of this number, Karan has begun to look for occurrences of four anywhere. He has a list of **T** integers, for each of them he wants to calculate the number of occurrences of the digit **4** in the decimal representation. He is too busy now, so please help him.

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

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

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

**1**≤**T**≤**10^5**- (Subtask 1):
**0**≤ Numbers from the list ≤**9**– 33 points. - (Subtask 2):
**0**≤ Numbers from the list ≤**10**– 67 points.^{9}

**Input:**
5
447474
228
6664
40
81
**Output:**
4
0
1
1
0

```
# cook your dish here
t = int(input())
for i in range(t):
count = 0
num = str(input())
for x in num:
if(x == "4"):
count += 1
print(count)
```

```
#include <iostream>
using namespace std;
int main() {
int t; cin>>t;
while(t--)
{
int cnt=0, n; cin>>n;
while(n>0)
{
int r = n%10;
if(r==4) cnt++;
n/=10;
}
cout<<cnt<<endl;
}
return 0;
}
```

```
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
for(int i=1;i<=n;i++)
{
int sum=0;
String s=sc.next();
for(int j=0;j<s.length();j++)
{
if(s.charAt(j)=='4')
sum++;
else
continue;
}
System.out.println(sum);
}
}
}
```

In our experience, we suggest you solve this Lucky Four CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Lucky Four CodeChef Solution

I hope this Lucky Four CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

**More Coding Solutions >>**