#include <bits/stdc++.h>
using namespace std;
int n, max2, cmax, c, n2, nr;
int main()
{
ifstream f("cifre4.in");
ofstream g("cifre4.out");
f >> n;
while(n)
{
c = n % 10;
n2 = n % 100;
if(c > cmax) cmax = c;
if(c == 4 || c == 9) nr ++;
if(n2 > 9 && n2 > max2) max2 = n2;
n = n / 10;
}
g << cmax << " " << nr << " " << max2;
return 0;
}