function main(input) {
  var input_num = Number(input);

  var two_count = 0;
  while(input_num > 0) {
    if (input_num %10 == 2) { 
      two_count++;
    }
    input_num = Math.floor(input_num / 10);
  }
  console.log(two_count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));