program caddi2018a
  implicit none
  integer i
  character(4) n
  logical :: m(4) = .false.

  read *, n
  forall(i = 1:len(n), n(i:i) == '2') m(i) = .true.
  print '(i0)', count(m)
end program caddi2018a
