#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>

using namespace std;

// PI from sample
// string pi = "3.14..."

vector<int> count_nums(string &str) {
	vector<int> nums(10, 0);
	for (auto c: str) {
		if (isdigit(c)) {
			nums[c - '0']++;
		}
	}

	return nums;
}


int main() {
/*
	auto nums = count_nums(pi);
	for (auto num: nums) {
		cout << num << endl;
	}
*/

	int pi_nums[10] = {
		20104,
		20063,
		19892,
		20011,
		19874,
		20199,
		19898,
		20163,
		19956,
		19841
	};

	string s;
	cin >> s;
	auto nums = count_nums(s);

	int miss = -1, collect = -1;
	for (int i = 0; i < 10; i++) {
		if (nums[i] > pi_nums[i]) {
			miss = i;
		}
		if (nums[i] < pi_nums[i]) {
			collect = i;
		}
	}

	cout << miss << " " << collect << endl;
	return 0;
}