unittest
{
	assert( [ "1222" ].parse.expand.solve == 3 );
	assert( [ "3456" ].parse.expand.solve == 0 );
	assert( [ "9592" ].parse.expand.solve == 1 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ns = input.front.strip.to!( dchar[] );
	return tuple( ns );
}

auto solve( dchar[] ns )
{
	return ns.count!( ( a ) => a == '2' );
}
