def main():
    N, M = map(int, input().split())

    if N == 2 or N <= M:
        ans = 1
    elif N == 4 and M < 4:
        ans = 2
    else:
        ans = -1

    print(ans)

main()