'use strict';

function main(arg) {
    const basic = arg.split(" ")[1];
    const less  = arg.split(" ")[0] % (arg.split(" ")[1]);
    console.log(less === 0 ? 0 : basic-less);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));