"use strict";

function main(input) {
  var lines = input.split('\n');
  var N = lines[0];
  console.log(N.split('').filter(function (x) {
    return x == 2;
  }).length);
}

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

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}
