// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

int n, m;

void main() {
    scan(n, m);

    if (m >= n) {
        writeln(1);
        return;
    }
    else {
        if (n & 1) {
            writeln(-1);
        }
        else {
            if (m >= n / 2) {
                writeln(2);
            }
            else {
                writeln(-1);
            }
        }
    }
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}