print("912345678"[int(input())%9])