#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#define REP(i, n) for(long long i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
	int n;
	cin>>n;
	string n_s = to_string(n);
	string res_s = "";
	REP(i, n_s.size()) {
		if(n_s[i] == '7') {
			res_s += '1';
		} else {
			res_s += '0';
		}
	}
	int res = stoi(res_s);
	cout<<res<<" "<<n - res<<endl;
}