a = int(input()) b = [] for i in range(4): b.append((a//(10**(3-i)))%10) for j in range(4): b[j] = (b[j]+3)%9 b[0],b[2] = b[2],b[0] b[1],b[3] = b[3],b[1] print(b[0],b[1],b[2],b[3],sep='')