#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>

using namespace std;

typedef vector<double> vec;
typedef vector<vec> mat;

int main()
{
	int pi_cnt[10]={20104,20063,19892,20011,19874,20199,19898,20163,19956,19841};
	string s;
	cin>>s;
	
	int cnt[10]={};
	for(int i=0;i<s.size();i++){
		if(s[i]=='.') continue;
		cnt[s[i]-'0']++;
	}
	
	int w,r;
	for(int i=0;i<10;i++){
		if(cnt[i]<pi_cnt[i]) r=i;
		if(cnt[i]>pi_cnt[i]) w=i;
	}
	
	cout<<w<<" "<<r<<endl;

    return 0;
}