#include #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!(p)) #define until(p) while(!(p)) using ll = std::int64_t; using P = std::tuple; int cnt[10] = {20104, 20063, 19892, 20011, 19874, 20199, 19898, 20163, 19956, 19841}; std::string S; int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cin >> S; int n, m; for(int i=0;i<=9;++i){ int c = std::count(S.begin(), S.end(), '0' + i); if(c - 1 == cnt[i]){ n = i; }else if(c + 1 == cnt[i]){ m = i; } } printf("%d %d\n", n, m); }