def main():
    y = int(input())

    if y%4 == 0:
        print(y+2)
    elif y%4 == 1:
        print(y+1)
    elif y%4 == 2:
        print(y)
    elif y%4 == 3:
        print(y+3)

if __name__ == '__main__':
    main()