jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]
import java.util.*;
import java.io.*;

public class Main {

	public static void main (String[] args) {
	   InputReader in = new InputReader(System.in);
	   int n = in.readInt();
	   int sum = 0;
	   int arr[] = new int[n]; 
	   for(int i = 0; i<n; i++) {
		  arr[i] = in.readInt();
		  while(arr[i] % 2 == 0) {
			  arr[i]/=2; 
			  sum++;
		  }
	   }
	   System.out.println(sum); 
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}
//  [java]
import java.util.Scanner;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();
		int count = 0;
		loop : while(true) {
			for(int i = 0; i < n; i++) {
				if(a[i]%2 == 0) {
					a[i] = a[i] / 2;
					count++;
					break;
				}
				if(i == n - 1) {
					break loop;
				}
			}
		}
		System.out.println(count);
	}
}
//  [java]
import java.util.*;

public class Main {

    static int ans = 0;

    private static void rec(int[] a) {

        boolean eNumExist = false;
        int index = -1;
        int max = 0;

        for (int i = 0; i < a.length; i++) {

            if (a[i] % 2 == 0) {
                eNumExist = true;
                a[i] = a[i]/2;
                break;
            }
        }

        if (eNumExist)
        {
            ans++;
            rec(a);

        }else{

            return;
        }
    }


    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int N = Integer.parseInt(scan.next());
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(scan.next());
        }

        rec(a);

        System.out.println(ans);
    }
}
//  [java]
import java.util.Scanner;

public class Main {
	static int dev(int[] a,int an){
		boolean flg = false;
		for(int i = 0;i < a.length;i++){
			if(a[i]%2 == 0){
				flg = true;
				a[i] /= 2;
				an++;
				break;
			}
		}
		if(flg)
			return dev(a,an);
		else
			return an;
	}
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n;
		n = sc.nextInt();
		int na[] = new int[n];
		for(int i = 0; i < n; i++)
			na[i] = sc.nextInt();
		
		System.out.println(dev(na,0));
		
	}
}
//  [cpp]
#include<cstdio>
inline int getint(){
  int ret = 0,f = 1;
  char c = getchar();
  while(c<'0'||c>'9'){
    if(c=='-')f=-1;
    c = getchar();
  }
  while(c>='0'&&c<='9')
    ret=ret*10+c-'0',c=getchar();
  return ret*f;
}
int N,a,t,s=0;
int main(){
  N=getint();
  while(N--){
    a=getint();
    asm volatile(
      "bsf %0,%1\n\t"
      :"=r"(t)
      :"r"(a)
    );
    s+=t;
  }
  printf("%d\n",s);
}
//  [cpp]
/*
    Name: *3 or /2 
    Author: FZSZ-LinHua
    Date: 2018 06 16
    Exec time: 2ms
    Memory usage: 256KB
    Score: 300
    Algorithm: Bit operation 
*/
# include "cstdio"

inline int read(){
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-') w=-w;
		ch=getchar();
	}
	while(ch>='0' && ch<='9'){
		s=s*10+ch-'0';
		ch=getchar();
	}
	return s*w;
}

inline int n_lowbit(int x){	//取出含有质因子2的个数 
	int count=0;
	while(x){
		if(x&1){
			return count; 
		}
		count++; 
		x>>=1; 
	}
	return count; 
} 

int
	ans, //记录答案 
	N; 

int main(){
	N=read();
	while(N--){
		ans+=n_lowbit(read()); //更新答案 
	}
	printf("%d",ans); 
	return 0; 
}
//  [cpp]
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,ans,x;
void read(int &x)
{
    int f=1;x=0;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    x*=f;
}
int PD(int x)
{
	int count=0;
    while(x){
        if(x&1){
            return count; 
        }
        count++; 
        x>>=1; 
    }
    return count; 
}
int main()
{
	read(n);
	for(int i=1;i<=n;i++)
	{read(x);
		ans+=PD(x);
	}
	printf("%d",ans);
}
//  [cpp]
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  int N, a;
  cin >> N;
  int ans = 0;
  vector<int> vec(N);

  for (int i = 0; i < N; i++){
    cin >> a;
    vec.at(i) = a;
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  bool flag = true;
  int check = 0;
  int cnt = 0;

  while (flag == true){
    if(flag == false) break;

    bool first = true;
    for (int i = 0; i < N; i++) {
      if(vec.at(i)%2 != 0){
        vec.at(i) = vec.at(i)*3;
      } else {
        if(first == true){
          vec.at(i) = vec.at(i)/2;
          first = false;
        } else {
          vec.at(i) = vec.at(i)*3;
        }
      }
    }
    if(first == true) break;
    ans++;
  }

  cout << ans << endl;


  return 0;
}
//  [cpp]
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    cin >> N;
    vl a(N);
    rep(i, 0, N) {
        cin >> a[i];
    }
    int count = 0;
    int top = 0;
    int loop = 0;
    while(true) {
        count = 0;
        top = 0;
        rep(i, 0, a.size()) {
            if (a[i] % 2 != 0 && top == 0) {
                a.erase(a.begin());
            } else if (a[i] % 2 != 0 && top > 0 && count > 0) {
                a[i] = a[i] * 3;
            }
            if (a[i] % 2 == 0 && count == 0) {
                a[i] = a[i] / 2;
                ++count;
            }
            ++top;
        }
        if (count == 0) {
            break;
        }
        ++loop;
    }
    cout << loop << endl;
    return 0;
}
//  [cpp]
#include <iostream>
#include <cstdlib>
#include <math.h>

int main()
{
    int n = 0;
    int a[10000];
    int i;
    int r = 0;
    int f = 0;
    std::cin >> n;
    for (i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    do {
        f = 0;
        for (i = 0; i < n; i++) {
            if (f == 0 && a[i] % 2 == 0) {
                a[i] = a[i] / 2;
                f = 1;
                r++;
                break;
            } else {
                a[i] = a[i] * 3;
            }
        }
        for (; i < n; i++) {
            a[i] = a[i] * 3;
        }
    } while (f > 0);
    std::cout << r << std::endl;
}
//  [c]
#include <stdio.h>

int main(){
  int n;  scanf("%d", &n);
  long ans = 0;
  for(int i=0; i<n; i++){
    long a;  scanf("%ld", &a);
    long count = 0;
    while(a%2==0){
      count++;
      a /= 2;
    }
    ans += count;
  }
  printf("%ld\n", ans);
  return 0;
}
//  [c]
#include <stdio.h>
int i;

int main(void)
{
    int a[10000],N,cnt=0;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<N;i++)
    {
        while(a[i]%2==0)
        {
            a[i]/=2;
            cnt++;
        }
    }
    
    printf("%d",cnt);
    
    
    return 0;
    
}
//  [c]
#include<stdio.h>

long long waru2(long long count , long long a){
  if(a%2 != 0){
    return count;
  }
  else{
    count ++;
    a /= 2;
  }
   waru2(count , a);
}


int main(void){
  
  int n;
  scanf("%d",&n);
    
 long long a[n];
  for(int i = 0;i <n;i ++){
    scanf("%lld",&a[i]);
  }
  
  long long count = 0;
  long long ans = 0;
  for(int i = 0;i < n;i ++){
    ans += waru2(count , a[i]);
   
  }
  
  printf("%lld\n",ans);
  
  return 0;
}
//  [c]
#include <stdio.h>

typedef struct{
	int max;
	int order;
}MAX;

void max_order(int a[], int size, MAX *ret){
	int max, order;
	max=a[--size];
	order=size;
	while(size){
		size--;
		if(max<a[size]){
			max=a[size];
			order=size;
		}
	}
	ret->max=max;
	ret->order=order;
}

int main(){
	int N, i, j, chain=0, ord;
	MAX data;
	scanf("%d", &N);
	int a[N], b[N], c;
	for(i=0;i<N;i++){
		scanf("%d", &a[i]);
	}
	for(i=0;i<N;i++){
		c=a[i];
		b[i]=0;
		while(c%2==0){
			b[i]++;
			c/=2;
		}
	}
	
	for(i=0;;i++){
		max_order(b, N, &data);
		if(data.max==0){
			break;
		}
		b[data.order]--;
	}
	printf("%d", i);
}
//  [c]
#include<stdio.h>
int main(void){
	int n,i,p,c=1;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	i=0;
	while(c==1){
		c=0;
		for(i=0;i<n;i++){
			if(c==1){
				a[i]*=3;
			}else{
				if(a[i]%2==0){
					a[i]/=2;
					c=1;
				}else{
					a[i]*=3;
				}
			}
		}
		if(c==1){
			p++;
		}
	}
	printf("%d",p);
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int N,i;
  long a[10005],count;
  char str[10000005],*p;
  
  
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  a[0]=atol(p);
  for(i=1;i<N;i++){
    p=strtok(NULL," \n");
  	a[i]=atol(p);
  }
  
  for(count=0;;){
    for(i=0;i<N;i++){
      if(a[i]%2==0){
        a[i]/=2;
        count++;
        break;
      }
    }
    if(i==N){
        break;
    }
    
  }
  
  printf("%ld\n",count);
  
  
  return 0;
}
//  [javascript]
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var list = myconv(input[1],4);
  var output = 0;
  for(var i = 0; i < N; i++){
    var tmp = list[i];
    while(tmp % 2 == 0){
          output++;
      tmp /= 2;
    }
  }
  myout(output);
}
Main(myin());
//  [javascript]
function main(input) {
  var N = input[0].split(" ")[0]-0;
  var list = input[1].split(" ").map(v=>v-0);
  var ans = 0;
  list.forEach(v=>{
    var cnt = 0;
    while(v%2==0){
      v/=2;
      cnt++;
    };
    ans += cnt;
  })
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))
//  [javascript]
'use strict'

function Main(input) {
  const N = Number(input.split('\n')[0]);
  let list = input.split('\n')[1].split(' ').map(x => Number(x));
  let count = 0;

  for(let i=0; i<N; i++) {
    while(list[i] % 2 === 0) {
      list[i] = list[i] / 2;
      count++;
    }
  }

  console.log(count);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [javascript]
var main = function(input){
input = input.split('\n');
var N = input[0];
var array = input[1].split(' ').map(x=>parseInt(x));
var count = 0;
for(var i=0;i<N;i++){
  while(array[i]%2 === 0){
    array[i]=array[i]*0.5;
    count++;
  }
}
  console.log(count);
    return 0;
}
main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [javascript]
function Main(s){
  s = s.split("\n");
  var n = +s[0];
  var a = s[1].split(" ").map(a=>+a);
  var ans = 0;
  for(var i = 0; i < n; i++){
    while(a[i] % 2 === 0){
      ans++;
      a[i] /= 2;
    }
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));
//  [javascript]
function Main(s){
	s=s.split(/\n|\s/);
	s.forEach(function(e,i,a){a[i]=Number(a[i]);});
	
	var a=0;
	for(var i=1;i<=s[0];i=(i+1)|0){
		while(s[i]%2==0){
			s[i]/=2;
			a++;
		}
	}
	
	console.log(a);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
        "bufio"
        "fmt"
        "os"
)

var sc = bufio.NewScanner(os.Stdin)

func ri() (n int){
        sc.Scan()
        for _, v := range sc.Bytes(){
                n = n*10 + int(v-48)
        }
        return
}

func main(){
        sc.Split(bufio.ScanWords)
        n := ri()
        ans := 0
        for i := 0; i < n; i++{
                for a := ri(); a&1 == 0; a>>= 1{
                        ans++
                }
        }
        fmt.Println(ans)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()
	ans := 0
	for i := 0; i < n; i++ {
		for a := ri(); a&1 == 0; a >>= 1 {
			ans++
		}
	}
	fmt.Println(ans)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	ans := 0
	for i := 0; i < n; i++ {
		tmp := sc.NextInt()
		for {
			if tmp%2 != 0 {
				break
			}
			tmp /= 2
			ans++
		}
	}
	fmt.Printf("%v\n", ans)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	as := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &as[i])
	}

	ans := 0
	for _, a := range as {
		facts := make(map[int]int)
		factoring(a, facts)
		ans = ans + facts[2]
	}
	fmt.Println(ans)
}

func factoring(n int, facts map[int]int) {
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			facts[i]++
			n = n / i
		}
	}
	if n != 1 {
		facts[n]++
	}
}
//  [go]
// すべてが奇数になってしまったら終了
// 毎回どれか偶数1つだけを2で割る -> 素因数2の数

package main
import "fmt"
func main(){
	var N int
	fmt.Scan(&N)
	ans := 0
	for i:=0; i<N; i++{
		var V int
		fmt.Scan(&V)
		for V>0 && V%2==0{
			V/=2
			ans++
		}
	}
	fmt.Println(ans)
}
//  [go]
package main

import "fmt"

func main() {
	// Code for C - *3 or /2
	var N int
	fmt.Scanf("%d", &N)

	var count, a int
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &a)
		for {
			if a%2 == 0 {
				a = a / 2
				count++
			} else {
				break
			}
		}
	}

	fmt.Println(count)
}
//  [ruby]
N = gets.to_i
# a&-a : LSB(Lowest Set Bit) 
puts gets.split.map(&:to_i).map{|a| (a&-a).bit_length - 1}.inject(&:+)
//  [ruby]
gets;p gets.split.map{|x|x=x.to_i;(x&-x).bit_length-1}.inject(:+)
//  [ruby]
_n = gets.chomp.to_i
ary = gets.chomp.split.map(&:to_i)

ans = ary.reduce(0) do |sum, i|
  sum + i.to_s(2).reverse.index("1")
end

puts ans
//  [ruby]
require 'prime'

n = gets.chomp.to_i
arr = gets.chomp.split(" ").map(&:to_i)

puts arr.map { |a|
    a.prime_division.to_h[2] || 0
}.sum
//  [ruby]
N = gets.to_i
a = gets.split.map(&:to_i).select(&:even?).inject(:*)
if a.nil?
    puts 0 ; exit
end
count = 0
while a.even?
    count += 1
    a /= 2
end
puts count
//  [ruby]
a=gets.chomp.to_i
b=gets.chomp.split(" ").map(&:to_i).inject(:*)
cnt=0
loop do
    if b.even?
        b = b/2
        cnt+=1
    else
        break
    end
end
puts cnt
//  [rust]
use std::io;
use std::io::{BufRead, Write};

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let _n: usize = buf.trim_right().parse().unwrap();
    buf.clear();
    input.read_line(&mut buf).unwrap();
    writeln!(
        output,
        "{}",
        buf.split_whitespace()
            .map(|x| x.parse::<usize>().unwrap())
            .map(|x| x.trailing_zeros())
            .sum::<u32>()
    ).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "3
5 2 4
", "3\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "4
631 577 243 199
", "0\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "10
2184 2126 1721 1800 1024 2528 3360 1945 1280 1776
", "39\n",
        );
    }
}
//  [rust]
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};
use std::{cmp, fmt};

fn main() {
    let a_s: Vec<u64> = {
        let mut sc = InputScanOnce::new(io::stdin(), 1024);
        let n = sc.next();
        sc.vec(n)
    };
    let r = a_s.into_iter().map(|a| a.trailing_zeros()).sum::<u32>();
    println!("{}", r);
}

struct InputScanOnce {
    buf: Vec<u8>,
    pos: usize,
}

#[allow(dead_code)]
impl InputScanOnce {
    fn new<R: Read>(mut reader: R, estimated: usize) -> Self {
        let mut buf = Vec::with_capacity(estimated);
        let _ = io::copy(&mut reader, &mut buf).unwrap();
        InputScanOnce { buf: buf, pos: 0 }
    }

    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
        T3::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        T::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                let l = self.next::<String>();
                l.as_bytes().iter().cloned().map(&mut f).collect()
            })
            .collect()
    }
}
//  [rust]
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let A = read![[i64]];

    let mut count = 0;

    for i in 0..N {
        let mut x = A[i];

        while x != 0 && x % 2 == 0 {
            x /= 2;
            count += 1;
        }
    }

    println!("{}", count)
}
//  [rust]
use whiteread::parse_line;

fn main() {
    let n: usize = parse_line().unwrap();
    let mut v: Vec<i32> = parse_line().unwrap();
    let mut k: usize = 0;
    let mut t: usize = 0;

    while t < n {
        if v[t] % 2 == 0{
            v[t] = v[t] / 2;
            k = k + 1;
            t = 0;
        } else {
            t = t + 1;
        }
    }

    println!("{}", k);
}
//  [rust]
extern crate core;

use std::collections::HashMap;
use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize)(list:[i64]));
    list.into_iter()
        .map(|x| prime_factor(x).get(&2).cloned().unwrap_or(0))
        .fold(0, |sum, i| sum + i)
        .to_string()
}

pub fn prime_factor(mut n: i64) -> HashMap<i64, i64> {
    let mut res: HashMap<i64, i64> = HashMap::new();
    let mut i = 2;
    while i * i <= n {
        while n % i == 0 {
            let v = match res.get(&i) {
                Some(v) => *v + 1,
                None => 1,
            };
            res.insert(i, v);
            n /= i;
        }
        i += 1;
    }
    if n != 1 {
        res.insert(n, 1);
    }
    res
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3\n5 2 4" => "3",
    test2: "4\n631 577 243 199" => "0",
    test3: "10\n2184 2126 1721 1800 1024 2528 3360 1945 1280 1776" => "39",
}
//  [rust]
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    let a: Vec<u64> = (&mut iter).take(n).map(|x| x.parse().unwrap()).collect();
    
    let mut ret = 0;
    for i in 0..n {
        let pf = prime_factors(a[i]);
        ret += *pf.get(&2).unwrap_or(&0);
    }
    println!("{}", ret);
}

#[doc = " n>=1"]
#[allow(dead_code)]
fn prime_factors(mut n: u64) -> std::collections::HashMap<u64, u64> {
    let mut ret = std::collections::HashMap::new();
    {
        let mut i = 2;
        while i * i <= n {
            while n % i == 0 {
                *ret.entry(i).or_insert(0) += 1;
                n /= i;
            }
            i += 1;
        }
    }
    if n != 1 {
        ret.insert(n, 1);
    }
    ret
}
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    var aryA = readInts()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    var ans = 0
    for i in 0..<n {
        while aryA[i] % 2 == 0 {
            aryA[i] /= 2
            ans += 1
        }
    }
    print(ans)
}
main()
//  [swift]
import Foundation

func main() {
  let n = Int(readLine()!)!
  let inputString = readLine()!
  var split: [Int] = inputString.components(separatedBy: " ").map{Int(String($0))!}

  var i = 0
  var res = 0
  for i in 1 ... n {
    var s = split[i-1]
    while(s%2==0) {
      s = s/2
      res += 1
    }
  }
  
  print(res)
}

main()
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
//    func enumerated() -> [(Int, Element)] {
//        return self.enumerate()
//    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//func gcd(x: Int, _ y: Int) -> Int {
//    if y == 0 {
//        return x
//    } else {
//        return gcd(y, x%y)
//    }
//}

/*************** メインプログラム ***************/

let N = readInt()!
var a = readIntSplit(by: " ")
var ans = 0
while a.count > 0 {
    a = a.filter{$0%2==0}.map{$0/2}
    ans += a.count
}
print(ans)
//  [typescript]
import { Hash } from "crypto";
import { access } from "fs";

class Input {
    private lines: string[];
    constructor(lines: string[]) {
        this.lines = lines;
    }

    public string(): string { return this.lines.shift() as string; }
    public int(): number { return parseInt(this.string()); }
    public intArray(): number[] { return this.string().split(" ").map(n => parseInt(n)); }
    public stringArray(): string[] { return this.string().split(" "); }

    public allLines(): string[] { return this.lines; }
    public allLinesInt(): number[] { return this.lines.map(s => parseInt(s)); }
    public allLinesIntArray(): number[][] { return this.lines.map(s => s.split(" ").map(n => parseInt(n))); }
    public allLinesStringArray(): string[][] { return this.lines.map(s => s.split(" ")); }
}


function calc(stdin: Input) {
    stdin.string();
    const a = stdin.intArray();

    let sum = 0;
    a.forEach(x => {
        for (var count = 0; (x & 1) == 0; count++ , x = x >> 1) { }
        sum+= count;
    });
    return sum;
}

function main(stdin: string) {
    console.log(calc(new Input(stdin.split("\n"))));
}

if (require.main && require.main.filename.indexOf("Main") >= 0) {
    main(require('fs').readFileSync('/dev/stdin', 'utf8'));
} else {
    main(require('fs').readFileSync('input.txt', 'utf8').trim());
}
//  [typescript]
import * as fs from "fs";

function main(lines: string[][]) {
  const numbers = lines[1].map((l) => parseInt(l));
  let countDiviedBy2 = 0;
  numbers.forEach((num) => {
    while (num % 2 === 0) {
      num /= 2;
      countDiviedBy2++;
    }
  });
  console.log(countDiviedBy2);
}

const lines = fs
  .readFileSync("/dev/stdin", "utf8")
  .split("\n")
  .map((l) => l.split(" "))
  .filter((input) => !(input.length === 1 && input[0] === ""));

main(lines);
//  [typescript]
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const as = input[1].split(" ").map(n => Number(n));
  let result = 0;
  for(const a of as){
    let num = a;
    while (num%2 === 0) {
      result++;
      num /= 2;
    }
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
import {stdin} from 'process';
let input = "";
stdin.on('data', x => {input += x});
stdin.on('end', () => {
    let [n, aline] = input.split('\n');
    let alist = aline.split(' ')
        .map(x=>x.trim()).map(x=>parseInt(x));
    let count = 0;
    for (let a of alist) {
        while (a % 2 === 0) {
            a = a / 2;
            count += 1;
        }
    }
    console.log(count);
});
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = Number(stdin.split('\n')[0])

const a = stdin
  .split('\n')[1]
  .split(' ')
  .map(Number)

const getDiv2Count = x => {
  let count = 0
  let num = x
  while (num % 2 === 0) {
    num /= 2
    count++
  }
  return count
}

const div2CountList = a.map(getDiv2Count)

console.log(div2CountList.reduce((p, c) => p + c))
//  [typescript]
const main = (input: void) => {
  const n: number = parseInt(input.split('\n')[0],10);
  const a: number = input.split('\n')[1].split(' ')
                      .map(x => parseInt(x,10));
  let cnt: number = 0;

  for (let i = 0; i < n; i ++) {
    while (a[i] %2 === 0) {
      a[i] = a[i]/2;
      cnt++ ;
    }
  }
  console.log(cnt);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
print(input().count("2"))
//  [python]
n=input()
ans=0
for i in range(4):
    if n[i]=="2":
        ans+=1
print(ans)
//  [python]
#
import sys
import math
import numpy as np
import itertools
# ひとつ入力
n = int(input())
answer = 0
while n>0:
    if n%10==2:
        answer += 1
    n = n // 10
print(answer)
//  [python]
#!/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:}}}
//  [python]
#-*- 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)
//  [java]
import java.io.*;

public class Main {

  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String s = br.readLine();

    br.close();

    int ans = 0;
    for(int i = 0; i < s.length(); i++){
      if(s.charAt(i) == '2') ans++;
    }

    System.out.println(ans);
  }
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		String a = "";
		Integer count = 0;
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8))) {
			a = br.readLine();
		}
		for(char x:a.toCharArray()) {
			if(x == '2') {
				count++;
			}
		}
		System.out.println(count);
	}
}
//  [java]
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long[] n = Arrays.stream(sc.nextLine().split("")).mapToLong(Long::parseLong).toArray();
		long c = Arrays.stream(n).filter(a -> a == 2).count();
		System.out.println(c);
	}

}
//  [java]
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        String s = stdin.nextLine();
        long ans = s.chars().filter(c -> c == '2').count();
        System.out.println(ans);
    }
}
//  [java]
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class Main implements Runnable {
    // 定数

    public static void main(String[] args) throws Exception {
        Thread.setDefaultUncaughtExceptionHandler((t, e)->System.exit(1));
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        int result = 0;
        String N = "";

        // 入力
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            N = br.readLine();
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (char c : N.toCharArray()) {
            if (c == '2') {
                result++;
            }
        }

        // 出力
        System.out.println(result);
    }
}
//  [cpp]
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main() {
	string S; 
	cin >> S; 
	int ans = 0; 
	for(int i = 0; i <= 3; i++){
		if(S.at(i) == '2'){ans ++;}
	}
	cout << ans << endl; 
}
//  [cpp]
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    int result = 0;
    char tmp;
    cin >> tmp;
    if(tmp=='2'){
        result++;
    }
    cin >> tmp;
    if(tmp=='2'){
        result++;
    }
    cin >> tmp;
    if(tmp=='2'){
        result++;
    }
    cin >> tmp;
    if(tmp=='2'){
        result++;
    }
    cout<<result<<endl;
    return 0;
}
//  [cpp]
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>


     
#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define pb push_back
#define sz size()
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

     
const ll MOD = 1e9 + 7;
const ll ZER = 0;



int main(){
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, 4)if(s[i] == '2')cnt++;
    cout << cnt << endl;
}
//  [cpp]
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size())cout << a[i] << " ";cout << "\n"
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;ll s = S.size(),ans = 0;
    rep(i,s){
        if(S[i] == '2')ans++;
    }
    cout << ans << endl;
}
//  [cpp]
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, string> P;
typedef tuple<int, string, string> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;

int solve() {
    int res = 0;
    while (n > 0) {
        if (n % 10 == 2)
            res++;
        n /= 10;
    }
    return res;
}

void input() {
    cin >> n;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}
//  [c]
#include <stdio.h>
int main(void){
	char a[5];
	int i,c=0;
	scanf("%s",a);
	for(i=0;i<4;i++){
		if(a[i]=='2')c++;
	}
	printf("%d",c);
	return 0;
}
//  [c]
s;main(a){for(;a=getchar()+1;)a-51?:s++;putchar(48+s);}
//  [c]
#include <stdio.h>

int main(){
	int N;
	int i=0;
	int count=0;
	scanf("%d",&N);
	while (i < 4){
		if (N%10 == 2) count++;
		N /= 10;
		i++;
	}
	printf("%d\n",count);
	return 0;
}
//  [c]
#include <stdio.h>

int main(void) {
	int N;
	int mareitaso = 0;
	if (scanf("%d", &N) != 1) return 1;
	while (N > 0) {
		mareitaso += N % 10 == 2;
		N /= 10;
	}
	printf("%d\n", mareitaso);
	return 0;
}
//  [c]
#include <stdio.h>

int main(){
  int N,c=0;
  scanf("%d",&N);
  for(int i=0;i<4;i++){
    if(N%10==2) c++;
    N/=10;
  }
  printf("%d\n",c);
  return 0;
}