#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s; cin >> s;
    vector<int> cnt = {20104, 20063, 19892, 20011, 19874, 20199, 19898, 20163, 19956, 19841};
    for(char c : s) if(isdigit(c)) cnt[c - '0']--;
    int ma = max_element(cnt.begin(), cnt.end()) - cnt.begin();
    int mi = min_element(cnt.begin(), cnt.end()) - cnt.begin();
    cout << mi << " " << ma << endl;
}