Problem:


Score : 100 points

Problem Statement

You are given an integer N that has exactly four digits in base ten.
How many times does 2 occur in the base-ten representation of N?

Constraints

1000 \leq N \leq 9999

Input

Input is given from Standard Input in the following format:

N

Output

Print the answer.

Sample Input 1

1222

Sample Output 1

3

2 occurs three times in 1222. By the way, this contest is held on December 22 (JST).

Sample Input 2

3456

Sample Output 2

0

Sample Input 3

9592

Sample Output 3

1



Sample input:
1222


Sample output:
3

Submission status: Accepted

Solution code:
s = str(input())

c = 0

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

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
while N > 0:
    if N % 10 == 2:
        ans += 1
    N //= 10
print(ans)

Submission status: Accepted

Solution code:
N = list(input())
ans = 0
for n in range(len(N)):
    if N[n] == "2":
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
N = stdin.readline().rstrip()
print(N.count('2'))

Submission status: Accepted

Solution code:
n = int(input())
print(str(n).count('2'))

Submission status: Accepted

Solution code:
N=list(input())
c=0
for i in range(len(N)):
    if N[i]=="2":
        c=c+1
print(c)

Submission status: Accepted

Solution code:
n = input()

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
N=list(input())
c=0
for i in N:
  if i=='2':
    c+=1
print(c)

Submission status: Accepted

Solution code:
N = input()
print(N.count('2'))

Submission status: Accepted

Solution code:
from collections import Counter
c = Counter(input())
print(c["2"])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy

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

Submission status: Accepted

Solution code:
print(str(input()).count("2"))

Submission status: Accepted

Solution code:
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり整数
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''


N = input()
ans = 0
for n in N:
    if n == "2":
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

print(input().count('2'))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    print(str(N).count("2"))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
cnt = 0
for i in s:
    if i == "2": cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n = list(str(i) for i in input())

print(sum(1 for i in n if i=='2'))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
cnt = 0
for i in range(len(N)):
	if N[i] == "2":
		cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
s = input().strip()

c = 0
for v in s:
  if v == "2":
    c += 1
    
print(c)

Submission status: Accepted

Solution code:
s=input()
print(s.count('2'))

Submission status: Accepted

Solution code:
N=str(input())
count=0
for i in N:
    if i=="2":
        count+=1
print(count)

Submission status: Accepted

Solution code:
# CADDi2018 for Beginners - A
# -*- encoding: UTF-8 -*-
nList = list(input())

m = 0
for i in nList:
  if i == "2" :
    m = m + 1

print(m)

Submission status: Accepted

Solution code:
n=input()

c=0
for i in n:
  if i=="2":
    c=c+1
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
ans = 0
for k in s:
  if k=='2':
    ans += 1
    
    
print(ans)

Submission status: Accepted

Solution code:
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    n = input()
    ans = 0
    for i in range(4):
        if n[i] == '2':
            ans += 1
    print(ans)
    return

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
n = input()
ans = 0
for c in n:
    if c == '2':
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin

s = stdin.readline().rstrip()

print(s.count("2"))

Submission status: Accepted

Solution code:
def main():
    N = input()
    ans = 0
    for i in N:
        if i == "2":
            ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N = input()

print(N.count('2'))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=input()
C=collections.Counter(n)
print(C["2"])

Submission status: Accepted

Solution code:
a = input()
b = list(a)

print(b.count('2'))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#X, Y = map(int, input().split())
N = str(input())

cnt = 0
for i in range(4) :
  if N[i] == "2" :
    cnt += 1
print (cnt)

Submission status: Accepted

Solution code:
n=input()
print(n.count('2'))

Submission status: Accepted

Solution code:
result = 0
for i in input():
  if i == "2":
    result += 1
print(result)

Submission status: Accepted

Solution code:
N=list(input())

print(N.count('2'))

Submission status: Accepted

Solution code:
N = list( input() )
istwo = [ x == "2" for x in N ]
print( sum( istwo ) )

Submission status: Accepted

Solution code:
n=input()
ans = 0
for s in n:
    if s=='2':
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
n = list(str(input()))
cnt = 0
for i in n:
    if i == "2":
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N = input()
ans = N.count("2")
print(ans)

Submission status: Accepted

Solution code:
N = input().strip()
print(N.count("2"))

Submission status: Accepted

Solution code:
N = list(input())
print(len([0 for i in range(len(N)) if N[i] == '2']))

Submission status: Accepted

Solution code:
S=input()

print(S.count('2'))

Submission status: Accepted

Solution code:
# 2019/11/28

print(input().count('2'))

Submission status: Accepted

Solution code:
#coding:utf-8

n = input()
print(n.count('2'))

Submission status: Accepted

Solution code:
S = input()
print(S.count('2'))

Submission status: Accepted

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = str(readline().rstrip().decode('utf-8'))
    print(n.count("2"))


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:

S = input()
ans = 0

for i in S:
  if i == "2":
    ans += 1
    
print (ans)

Submission status: Accepted

Solution code:
N = str(input())
ans = 0
for i in N:
    if i == '2':
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
 
##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力
 
# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと
 
##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順
 
# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    N = str(N)
    ans = 0
    for i in N:
        if i == "2":
            ans += 1
            
    print(ans)
    
    
    
if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
print(list(input()).count("2"))

Submission status: Accepted

Solution code:
n = input()
cnt = 0
for i in range(4):
    if n[i] == '2':
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n = input()
ans = 0
for i in n:
  if i == "2":
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = input()
count = 0
for i in range(4):
    if N[i] == "2":
        count = count + 1
print(count)

Submission status: Accepted

Solution code:
n=input()
count=0
for i in range(4):
    if n[i]=="2":
        count+=1
print(count)

Submission status: Accepted

Solution code:
n=input()
N=list(n)
count=0
for i in range(4):
    if N[i]=='2':
        count+=1
print(count)

Submission status: Accepted

Solution code:
n=str(input())

def solve(n):
  return n.count('2')

print(solve(n))

Submission status: Accepted

Solution code:
N=input()
ans=0
for i in range(4):
  if(N[i]=='2'):
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(N: int):
    print(str(N).count('2'))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main(n):
    print(str(n).count('2'))


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

Submission status: Accepted

Solution code:
n=str(input())
print(n.count('2'))

Submission status: Accepted

Solution code:
from collections import Counter
N = input()
counter = Counter(N)
print(counter["2"])

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n = str(input().rstrip('\n'))
    print(n.count("2"))


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
N=input()
print(N.count('2'))

Submission status: Accepted

Solution code:
s=list(str(input()))
ans=0
for i in range(4):
    if s[i]=='2':
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
s=input()
print(s.count("2"))

Submission status: Accepted

Solution code:
n = list(input())
ans =0
for i in range(len(n)):
  if n[i] =='2':
    ans +=1
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin

def solve() :
    N = stdin.readline().rstrip()
    ans = 0
    for x in N:
        if(x == "2") :
            ans += 1

    print(ans)
solve();

Submission status: Accepted

Solution code:
n = list(input())

cnt = 0

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

Submission status: Accepted

Solution code:
def solve():
  print(input().count("2"))
solve()

Submission status: Accepted

Solution code:
i = input()
print(i.count("2"))

Submission status: Accepted

Solution code:
N = input()
r = N.count("2")
print(r)

Submission status: Accepted

Solution code:
def main():
    N = input()
    cnt = 0
    for c in N:
        if c == "2": cnt += 1
    return cnt


if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
s=list(input())
cnt=0
for i in range(4):
    if(s[i]=="2"):
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
a= input()
print(a.count('2'))

Submission status: Accepted

Solution code:
n = input()
ans = 0
for i in range(0,4):
    if n[i] == '2':
        ans +=1

print(ans)

Submission status: Accepted

Solution code:
N = input()
c = 0
if N[0] == "2":
  c += 1
if N[1] == "2":
  c += 1
if N[2] == "2":
  c += 1
if N[3] == "2":
  c += 1
print(c)

Submission status: Accepted

Solution code:
N = input()
ans = 0
for c in N:
    if c == "2":
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n=list(input())
print(n.count("2"))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

N = input()

# print(N)

result = 0

for i in range(len(N)):
    # print(N[i])
    if N[i] == '2':
        result += 1

print(result)

Submission status: Accepted

Solution code:
print(list(input()).count('2'))

Submission status: Accepted

Solution code:
s = input()
ans = 0
for i in s:
    if i == '2':
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int):
    print(str(N).count('2'))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# x,y=map(int,input().split())
n=input()

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

Submission status: Accepted

Solution code:
N = list(input())
ans = N.count("2")
print(ans)

Submission status: Accepted

Solution code:
N=input()
c=0
for i in N:
    if(i=='2'): c+=1
print(c)

Submission status: Accepted

Solution code:
S = input()
ans = 0
for i in range(4):
    if S[i] == "2":
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N=str(input())
print(N.count('2'))

Submission status: Accepted

Solution code:
# caddi2018bA - 12/22
def main():
    n = input()
    print(n.count("2"))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()
ans = 0
for s in S:
    if s == "2":
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = input()
c=n.count("2")
print(c)

Submission status: Accepted

Solution code:
S = list(input())
print(S.count("2"))

Submission status: Accepted

Solution code:
n = input()
res = 0
for i in range(4):
    if n[i] == "2":
        res += 1
print(res)

Submission status: Accepted

Solution code:
def solve(n):
    return len(list(filter(lambda _: _=="2", list(n))))
n = input()
print(solve(n))

Submission status: Accepted

Solution code:
N = input().rstrip()

print(N.count('2'))

Submission status: Accepted

Solution code:
n=list(input())
print(n.count('2'))

Submission status: Accepted

Solution code:
N = str(input())
ans = 0
for i in range(0, len(N)):
    if N[i] == "2":
        ans = ans + 1
print(ans)

Submission status: Accepted

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

n = sys.stdin.readline().rstrip()
print(n.count('2'))

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N = input()
    print(N.count("2"))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = input()
cnt = 0
for s in N:
  if s == "2":
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
###template###
import sys
input = sys.stdin.readline
def mi(): return map(int, input().split())
###template###

N = input()

print(N.count('2'))

Submission status: Accepted

Solution code:
n = list(map(int, input()))
cnt = 0
for i in n:
    if i == 2:
        cnt +=1
print(cnt)

Submission status: Accepted

Solution code:
N = str(input())
cnt = 0
for i in range(len(N)):
        if N[i] == "2":
                cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = [i for i in input()]
print(N.count("2"))

Submission status: Accepted

Solution code:
def main():
    N = input()
    ans = 0
    for c in N:
        if c == "2":
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = str(input())
ans = 0
for i in range(4):
    if N[i] == "2":
        ans += 1
    else:
        ans += 0
print(ans)

Submission status: Accepted

Solution code:
a=input()

b=a.count("2")

print(b)

Submission status: Accepted

Solution code:
s = input()

print(s.count('2'))

Submission status: Accepted

Solution code:
n = input()

print(n.count("2"))

Submission status: Accepted

Solution code:
n = str(int(input()))

count = 0
for c in n:
    if c == '2':
        count += 1

print(count)

Submission status: Accepted

Solution code:
n =input()
t = 0
for i in range(len(n)):
  if n[i]=='2':
    t +=1
print(t)

Submission status: Accepted

Solution code:
s=input()
count=0
for i in range(4):
  if s[i]=='2':
    count+=1
print(count)

Submission status: Accepted

Solution code:
s = input()
count = 0
for i in range(4):
    if s[i] == '2':
        count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = str(n)
print(l.count("2"))

Submission status: Accepted

Solution code:
n = list(map(int, input()))
cnt = 0
for i in n:
    if i == 2:
        cnt +=1
print(cnt)

Submission status: Accepted

Solution code:
n = list(map(int, input()))
cnt = 0
for i in range(4):
    if n[i] == 2:
        cnt +=1
print(cnt)

Submission status: Accepted

Solution code:
S = input()
cnt=0
for i in S:
  if i == '2':
    cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

ans = str(N).count("2")

print(ans)
print()

Submission status: Accepted

Solution code:
S = input()
c = 0
for i in range(4):
  if S[i] == '2':
    c += 1
print(c)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
def dump(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    n = input()
    res = 0
    for c in n:
        if c=='2':
            res += 1;
    print(res)
    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}

Submission status: Accepted

Solution code:
n=int(input())
ans=0
while n>0:
    if n%10==2:
        ans+=1
    n=n//10
print(ans)

Submission status: Accepted

Solution code:
ans = 0
for i in input():
    if i == '2':
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
s = input()
ct = 0
for i in range(4):
  if s[i] == '2':ct+=1
print(ct)

Submission status: Accepted

Solution code:
a = list(input())
print(a.count("2"))

Submission status: Accepted

Solution code:
import re

N = input()

if "2" in N:
    L = re.findall("2",N)
    print(len(L))
else:
    print("0")

Submission status: Accepted

Solution code:
S = input()

ans = 0

for c in S:
  if c == "2":
    ans += 1
    
print(ans)

Submission status: Accepted

Solution code:
n=input()
count=0
for i in range(len(n)):
  if n[i] == '2':
    count += 1
print(count)

Submission status: Accepted

Solution code:
N = list(input())
cnt = 0
for i in N:
    if i == "2":
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
print(len([i for i in input() if i=='2']))

Submission status: Accepted

Solution code:

n = input()
print(n.count('2'))

Submission status: Accepted

Solution code:
input = input()
print(len([i for i in input if int(i) == 2]))

Submission status: Accepted

Solution code:
str_num = input()
count = 0
for c in str_num:
  if c == "2":
    count += 1
print(count)

Submission status: Accepted

Solution code:
#-*- coding:utf-8 -*-
import numpy as np

s = input()
list_s = list(s)

count=0
for i in list_s:
    if i == '2':
        count+=1

print(count)

Submission status: Accepted

Solution code:
print raw_input().count('2')

Submission status: Accepted

Solution code:
num = int(raw_input())
total = 0

while num > 0:
	if num%10 == 2:
		total +=1
	num = num/10

print total

Submission status: Accepted

Solution code:
a = int(input())

def f1(i):
    lst = []
    while i > 0:
        lst.append(i%10)
        i //= 10
    lst.reverse()
    return lst

b = f1(a)
c = 0
for i in range(4):
    if b[i]==2:
        c += 1
    else:
        c = c

print(c)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def main():
    print((input().strip()).count('2'))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
string = str(input())
print(sum([1 for ch in string if ch == '2']))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=[x for x in input().split("2")]
print(len(s)-1)

Submission status: Accepted

Solution code:
x = input()
cnt = 0
for i in x:
  if i == '2':
    cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
try:
    print(input().count('2'))
except EOFError:
    pass

Submission status: Accepted

Solution code:
s=input()
ans=0
for moji in s:
  if moji == '2':
    ans += 1
    
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 31 14:08:31 2018

@author: Yamazaki Kenichi
"""
a = input()
print(a.count('2'))

Submission status: Accepted

Solution code:
a = int(input())

answer = 0

if a//1000 == 2:
    answer += 1

if (a//100)%10==2:
    answer += 1

if (a//10)%10==2:
    answer += 1

if (a//1)%10==2:
    answer += 1
print(answer)

Submission status: Accepted

Solution code:
N = input()
ans = N.count('2')
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
cnt=0
while n >= 1:
    if n%10==2:
        cnt+=1
    n=int(n/10)
print(cnt)

Submission status: Accepted

Solution code:
def main():
    txt = input()
    print(txt.count('2'))
    return

main()

Submission status: Accepted

Solution code:
num = input()
ans = 0

while num > 0:
    if num%10 == 2:
        ans += 1
    num /= 10

print ans

Submission status: Accepted

Solution code:
num = input()
print(num.count('2'))

Submission status: Accepted

Solution code:
import sys

a = list(input())

cnt = 0
for i in range(len(a)) :
    if a[i] == '2':
        cnt +=1

print(cnt)

Submission status: Accepted

Solution code:
N=list(input())
print(N.count('2'))

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = S()
    r = 0
    for c in n:
        if c == '2':
            r += 1

    return r


print(main())

Submission status: Accepted

Solution code:
l = list(map(int,input()))
count = 0
for item in l:
  if item == 2:
    count += 1
print(count)

Submission status: Accepted

Solution code:
a = list(input())
b=0
for i in range(len(a)):
  if a[i] == "2":
    b+=1
print(b)

Submission status: Accepted

Solution code:
N = input()

cnt = 0
for n in N:
    if n == '2':
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
from collections import Counter
print(Counter(list(input()))['2'])

Submission status: Accepted

Solution code:
n = list(input())
cou = 0

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

Submission status: Accepted

Solution code:
s=input()
c=s.count("2")
print(c)

Submission status: Accepted

Solution code:
res = sum([True for _ in input() if _ == '2'])
print(res)

Submission status: Accepted

Solution code:
from collections import Counter
print Counter(raw_input())['2']

Submission status: Accepted

Solution code:
n=input()
c=0
for i in range(4):
  if n[i]=="2":c+=1
print(c)

Submission status: Accepted

Solution code:
N=input()
N_str=str(N)
Result=0
for n in N_str:
    if n=="2":
        Result+=1
print Result

Submission status: Accepted

Solution code:
import collections
line = list(input())
print(line.count('2'))

Submission status: Accepted

Solution code:
N= input()
s = N.count("2")
print(s)

Submission status: Accepted

Solution code:
num = input()
print(sum([int(n=='2') for n in num]))

Submission status: Accepted

Solution code:
a=input()
ans=0
for i in range(4):
    if a[i]=="2":
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
n = input()
a = 0

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

Submission status: Accepted

Solution code:
print(len([x for x in input() if x == '2']))

Submission status: Accepted

Solution code:
n = str(input())
count =0
for i in range(len(n)):
  if n[i] == '2':
    count += 1
print(count)

Submission status: Accepted

Solution code:
N = raw_input()
print(N.count('2'))

Submission status: Accepted

Solution code:
l=list(input())
print(l.count("2"))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(raw_input())

count = 0

for i in xrange(4):

    if (n % 10) == 2:
        count += 1

    n /= 10

print count

Submission status: Accepted

Solution code:
a = input()
print(len([i for i in a if i == '2']))

Submission status: Accepted

Solution code:
suuji = input()
kaisu = 0
for i in suuji:
	if i == "2":
		kaisu += 1
	else:
		pass
print(kaisu)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
#a = int(input())
# スペース区切りの整数の入力
#b, c = map(int, input().split())
# 文字列の入力
#s = input()
# 出力
#print("{} {}".format(a+b+c, s))

N = int(input())
print("{}".format(str(N).count('2')))