const readline = require("readline");

let lines=[];
const reader = readline.createInterface({
	input: process.stdin,
	output: process.stdout
});

reader.on("line", function (line) {
    lines.push(line);
});

reader.on("close", function () {
    lines[0] -= lines[1];
    lines[0] %= lines[2];
    console.log(lines[0])
});