function Main(input) { var line = input.split(" "); var n = +line[0]; var m = +line[1]; rapt(n, m); } function rapt(n, m) { var day = 0; if (n % 2 == 1) { day += (m >= n) ? 1 : -1; } else if (n % 2 == 0) { if (m >= n) { day += 1; } else { day += (m >= (n / 2)) ? 2 : -1; } } console.log(day); } Main(require("fs").readFileSync("/dev/stdin", "utf8"));