#include #include #include #include using namespace std; int a[10] = { 1954, 1997, 1986, 1986, 2043, 2082, 2017, 1953, 1962, 2020 }; int b[10]; int main() { string s; cin >> s; for (int i = 2; i < s.size(); i++) { b[s[i] - '0']++; } int g = 0; int l = 0; for (int i = 0; i < 10; i++) { if (a[i] < b[i]) { l = i; } if (a[i] > b[i]) { g = i; } } if (l != g) { cout << g << " " << l << endl; } else { cout << s[0] << " " << 3 << endl; } return 0; }