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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = input().split()
b = 0
for i in range(2):
    a.sort()
    b = b + int(a[0])
    a[0] = str(int(a[0]) - 1)
print(b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
print(4-input().count('2'))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = list(input())

cnt = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
print(1)

Submission status: Wrong Answer

Solution code:
n = int(raw_input())

count = 0

for i in xrange(4):

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

    n /= 10

print count

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(b)

Submission status: Wrong Answer

Solution code:
a,b,c,d = map(int,input())

if a==2:
  a=1
if b==2:
  b=1
if c==2:
  c=1
if d==2:
  d=1
  
print(a+b+c+d)

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8

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

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = input()
num=0

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

Submission status: Wrong Answer

Solution code:
text = input()
cnt = 0
for i in range(len(text)):
  if i == 2:
    cnt += 1
print (i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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 = input()
cnt = 0
for i in range(len(n)):
    if n[i] == "2":
        cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = list(input())
count = 0

for i in range(0, len(A)):
    if A[i] == "2":
        count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__=="__main__":
  n=input()
  print(n.count('2'))

Submission status: Accepted

Solution code:
from sys import stdin
rs = lambda : stdin.readline().strip()
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def main():
    s = rs()
    ans = s.count('2')
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    s=SI()
    count=0
    for i in range(4):
        if s[i]=="2":
            count+=1
    print(count)
        
        
        
        
    
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
input_num = str(input())
cnt_2_in_str = lambda x: 1 if x == '2' else 0
print(sum(map(cnt_2_in_str,input_num)))

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:
print(len([c for c in input() if c == '2']))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = input()

    print(N.count("2"))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=pin()[:-1]
  print(N.count("2"))
  return 

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#CADDi 2018 for Beginners a
n=input()
ans=n.count('2')
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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(input())
cnt=0
for i in n:
    if i == '2': cnt+=1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()

print(N.count('2'))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = SS()

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

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = readline().decode('utf-8').strip()
    print(N.count('2'))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
#N, P = map(int,input().split())
#N = int(input())
#l = list(map(int,input().split()))
#s = list(map(str,input().split()))
s = list(input())
print(s.count("2"))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = S()
print(n.count('2'))

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = input()

print(N.count("2"))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = input()
    print(N.count("2"))
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S=input()
    print(S.count("2"))

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = input()
    print(sum([n == '2' for n in N]))
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()

print(n.count('2'))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()

print(n.count('2'))

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()

print(n.count("2"))

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

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

Submission status: Accepted

Solution code:
s = list(input())

print (s.count('2'))

Submission status: Accepted

Solution code:
S = str(input())
ans = 0
for i in range(len(S)):
  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:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
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)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
c = Counter(S())
print(c["2"])

Submission status: Accepted

Solution code:
N = input()

c = N.count('2')

print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from heapq import heapify, heappop, heappush
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret

# ここから書き始める
n = input()
ans = n.count("2")
print(ans)

Submission status: Accepted

Solution code:
import heapq
from sys import stdin
input = stdin.readline

#入力
# s = list(input()[0:-1])
# n = int(input())
# A,B,M = map(int, input().split())
# a = list(map(int,input().split()))
# b = list(map(int,input().split()))
# w = [int(input()) for i in range(n)]

# xyc=[]
# for i in range(M):
#     x,y,c = map(int, input().split())
#     xyc.append((x,y,c))
def main():
    n = int(input())
    ans = 0
    while n >0:
        if n %10 == 2:
            ans += 1
        n= n//10
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

def solve():
    str = (input().rstrip())
    cnt = 0
    for s in str:
        if(s == '2'):
            cnt += 1
    
    print(cnt)
        
if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    N=int(input())
    print(str(N).count('2'))
    
resolve()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    cnt=0
    n=input()
    for i in n:
        if i=='2':
            cnt+=1
    print(cnt)
resolve()

Submission status: Accepted

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

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 sys

input = sys.stdin.readline


def main():
    N = int(input())

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = read().rstrip().decode()
print(s.count('2'))

Submission status: Accepted

Solution code:
s = input() #sys.stdin.readlineは最後が改行
print(s.count('2'))

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=input()
    ans=0
    for nn in n:
        if nn=="2":ans+=1
    print(ans)

if __name__=='__main__':
    main()

Submission status: Accepted

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

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()
print(s.count('2'))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
ans=0
if s[0]=='2':
    ans+=1
if s[1]=='2':
    ans+=1
if s[2]=='2':
    ans+=1
if s[3]=='2':
    ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# CADDi 2018 for Beginners: A – 12/22
print(input().count('2'))

Submission status: Accepted

Solution code:
# CADDi 2018 for Beginners: A – 12/22
n = input()
print(n.count('2'))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = S()
    print(n.count("2"))
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():

    N= input()
    NN= [int(c) for c in N]
    print(NN.count(2))



resolve()

Submission status: Accepted

Solution code:
N =input()

print(N.count("2"))

Submission status: Accepted

Solution code:

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

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:
s=input()
ans=0
for i in range(len(s)):
    if s[i]=="2": ans+=1
print(ans)

Submission status: Accepted

Solution code:
count = 0
S = list(input())
for ch in S:
  if ch == '2':
    count += 1
print(count)

Submission status: Accepted

Solution code:
n = str(input())

res = 0
for i in n:
    if i == "2":
        res += 1

print(res)

Submission status: Accepted

Solution code:
#template
from sys import setrecursionlimit
setrecursionlimit(10**6)
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
#template
N = list(input())
c = Counter(N)
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:
s = input()

print(s.count("2"))

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = input()
ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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