'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const N = args[0][0]
	let cnt = 0
	if (N[0] === '2') cnt++
	if (N[1] === '2') cnt++
	if (N[2] === '2') cnt++
	if (N[3] === '2') cnt++
	console.log(cnt)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
