You are given a four-digit integer N in base ten. Determine how many times the digit 2 appears in the base-ten representation of N. The input is given in the format of N, and the output should be the count of the digit 2. The constraints are that N lies between 1000 and 9999 (inclusive).

# Buggy version:
n=input()

if n.count('2')==1:
  print(1)
if n.count('2')==2:
  print(2)
if n.count('2')==3:
  print(3)
if n.count('2')==4:
  print(4)

# Fixed version:
n=input()
if n.count('2')==0:
  print(0)
if n.count('2')==1:
  print(1)
if n.count('2')==2:
  print(2)
if n.count('2')==3:
  print(3)
if n.count('2')==4:
  print(4)

# Buggy version:

N=int(input())
cnt=N.count('2')
print(cnt)

# Fixed version:

N=input()
cnt=N.count('2')
print(cnt)

# Buggy version:
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [str(i) for i in input().split()]
    
    count = 0

    for  i in range(a[0]):
        if "2" == i:
            count +=1
    print(count)


# Fixed version:
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [str(i) for i in input().split()]

    count = 0

    for  i in a[0]:
        if "2" == i:
            count +=1
    print(count)

# Buggy version:
print(input().count('2')

# Fixed version:

print(input().count("2"))

# Buggy version:
N=list(input())
c=0
for i in N:
  if i==2 :
    c+=1
print(c)

# Fixed version:
N=list(input())
c=0
for i in N:
  if i=='2':
    c+=1
print(c)

# Buggy version:
N = list( input() )
istwo = [ x == 2 for x in N ]
print( sum( istwo ) )


# Fixed version:
N = list( input() )
istwo = [ x == "2" for x in N ]
print( sum( istwo ) )

# Buggy version:
def main(n):
    print(str(n).count('2'))


if __name__ == '__main__':
    n = int(input())
    main()


# Fixed version:
def main(n):
    print(str(n).count('2'))


if __name__ == '__main__':
    n = int(input())
    main(n)

# Buggy version:
import sys
import collections
import copy
import math
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
a = int(input())
ans = 0
for i in range(4):
    if a%10 == 2:
        ans += 1
    a = a//10

# Fixed version:
import sys
import collections
import copy
import math
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
a = int(input())
ans = 0
for i in range(4):
    if a%10 == 2:
        ans += 1
    a = a//10
print(ans)

# Buggy version:
n = list(int(input())

cnt = 0

for i in range(len(n)):
    if n[i] == 2:
        cnt += 1
print(cnt)

# Fixed version:
n = list(input())

cnt = 0

for i in range(len(n)):
    if n[i] == "2":
        cnt += 1
print(cnt)

# Buggy version:
#%%
N = input()
cnt = 0
for i in N:
    if i == '2':
        cnt +- 1
print(cnt)



# Fixed version:
#%%
N = input()
cnt = 0
for i in N:
    if i == '2':
        cnt += 1
print(cnt)

# Buggy version:
s=input()
ans=0
for moji in s:
  if mojl == '2':
    ans += 1
    
print(ans)


# Fixed version:
s=input()
ans=0
for moji in s:
  if moji == '2':
    ans += 1
    
print(ans)

# Buggy version:
a = input()
b = 0
for i in range(len(a)):
if a[i]==2:
b=b+1
print(b)


# Fixed version:
a=input()
b=0
for i in range(len(a)):
  if a[i]=="2":
    b=b+1
  else:
    b=b
print(b)

# Buggy version:
suuji = input()
print('input', suuji)
kaisu = 0
for i in suuji:
	if i == "2":
		kaisu += 1
	else:
		pass
print(kaisu)

# Fixed version:
suuji = input()
kaisu = 0
for i in suuji:
	if i == "2":
		kaisu += 1
	else:
		pass
print(kaisu)

# Buggy version:
n=int(input())
ans=0
for i in range(4):
  if n%10=2:
    ans+=1
  n=n/10
print(ans)

# Fixed version:
count=0
n=int(input())

for i in range(4):
    if n%10 == 2:
        count = count+1
    n = int(n/10)
        
print(count)

# Buggy version:
a = input()
b = 0
for i in range(len(a)):
if a[i]==2:
b=b+1
else:
b=b
print(b)


# Fixed version:
a = input()
a = str(a)
b = 0
for i in range(len(a)):
    if a[i]=="2":
        b=b+1
    else:
        b=b
print(b)

# Buggy version:
N = int(input())
ans = 0
for i in range(4)
 a = N%10
 if a==2:
  ans += 1
 N /= 10
print(ans)


# Fixed version:
N = int(input())
ans = 0
for i in range(4):
 a = N%10
 if a==2:
  ans = ans+ 1
 N /= 10
 N = int(N)
print(ans)

# Buggy version:
text = input()
cnt = 0
for i in text:
	print (i)
	if i == "2":
		cnt += 1
print (cnt)

# Fixed version:
text = input()
cnt = 0
for i in text:
	if i == "2":
		cnt += 1
print (cnt)

# Buggy version:
#coding:utf-8

s=input()
res =0
for i in s:
    if i==2:
        res+=1

print(res)

# Fixed version:
#coding:utf-8

s = input()
res = 0

for i in s:
	if i =='2':
		res +=1
		
print(res)

# Buggy version:
N = map(str,input())
M = [M for M in N]
print(M.count("2")


# Fixed version:
N = map(str,input())
M = [M for M in N]
print(M.count("2"))

# Buggy version:
s=input()
ans=0
for i in len(s):
    if s[i]=="2": ans+=1
print(ans)

# Fixed version:
s = input()

ans = 0

for i in range(len(s)):
    if s[i] == '2':
        ans += 1

print(ans)

# Buggy version:
n=input()
ans=0
for i in range(4):
  if n[i]="2":
    ans+=1
print(ans)

# Fixed version:
n=input()

ans=0
for i in range(len(n)):
  if n[i]=="2":
    ans+=1
print(ans)

# Buggy version:
text = input()
cnt = 0
for i in range(len(text)):
	if text[i] == "2":
		cnt += 1
print (i)

# Fixed version:
n = input()
cnt = 0
for i in range(len(n)):
    if n[i] == '2':
        cnt = cnt+1
print(cnt)

# Buggy version:
N = int(input())
print(N.count("2"))

# Fixed version:
N=input()

print(N.count("2"))

# Buggy version:
n=list(input())
print(n.count('2))

# Fixed version:
n = list(input())

print(n.count('2'))