#include using namespace std; typedef long long ll; using P = pair; int main(void){ string s; cin >> s; ll a = 0; ll n = 0; for(int i = 0; i < s.length(); i++){ n *= 10; n += (s[i] - '0'); if(s[i] == '7'){ a += 1; } else{ a += (s[i] - '0'); } a *= 10; } ll b = n - a; cout << a << " " << b << endl; return 0; }