"use strict";
const Main = (input) =>{
   let xs = input.trim().split('');
   let count = 0;
   for(let i=0; i<4; i++){
     if(xs[i]==2){
       count += 1;
     }else{
       count += 0;
     }
   }
   console.log(count);

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