#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
	string s;
	cin >> s;
	int x[10] = {
 		20104, 20063, 19892, 20011, 19874, 20199, 19898, 20163, 19956, 19841
	};
	for(char c : s){
		if(c != '.'){ --x[c - '0']; }
	}
	cout << find(x, x + 10, -1) - x << ' ' << find(x, x + 10, 1) - x << '\n';
}