const reader = require("readline").createInterface({ input: process.stdin, output: process.stdout }); let lines = []; reader.on("line", line => { lines.push(line); }); reader.on("close", () => { const newArr = lines[0].split(' ').map(str => parseInt(str, 10)) if (newArr[2] >= newArr[1]) { console.log(newArr[2] - 2) } else if (newArr[2] < newArr[1]) { console.log(newArr[2] - 1) } else if (newArr[2] <= newArr[0]) { console.log(0) } });