Y = int(input()) if Y >=1970 and Y<=2017: print(2017-Y) else: print("NG")