function main(input){
    lines = input.split("");

    var count=0;
    for(var i=0;i<4;i++){
        if(lines[i]==2){
            count++;
        }
    }

    console.log(count);
}

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