arr = map(int,list(raw_input())) arrb = [0 for i in range(len(arr))] for i in range(len(arr)): if arr[i] == 7: arr[i] -= 1 arrb[i] += 1 def arrtoi(arr): ans = 0 i = len(arr)-1 for j in arr: ans += j * 10**i i -= 1 return ans print arrtoi(arr),arrtoi(arrb)