#include <iostream>
#include <string>
#include <fstream>
int main()
{
	int b[10]={20104,20063,19892,20011,19874,20199,19898,20163,19956,19841,};
	std::string s;std::cin >> s;int n[10] = {0};
	for(const char c : s)
		if(c != '.' && (c >= '0' && c <= '9'))
			n[c - '0']++;
	int t, f;
	for(int i = 0; i < 10; i++){		
		if(n[i] == b[i] + 1)
			f = i;

		if(n[i] == b[i] - 1)
			t = i;
	}

	std::cout << f << " " << t << std::endl;
	return 0;
}