N = list(input()) ans = [] for i in range(len(N)): if N[i] == "7": ans.append("1") else: ans.append("0") N0="".join(N) ans0="".join(ans) print(int(N0)-int(ans0),int(ans0))