/**
 * 
 * @param {string} input 
 */
function main(input) {
  const inputList = input.split(" ");
  const charge = Number(inputList[0]);
  const have = Number(inputList[1]);
  const max = Number(inputList[2]);
  const listenMax = have % charge;

  const ans = max > listenMax ? listenMax : max;
  console.log(ans);
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));
