function main(arg) {
    arg = arg.split("\n")
    arg = arg[0].split(" ")
    arg[0] = parseInt(arg[0], 10)
    arg[1] = parseInt(arg[1], 10)
    var n1 = Math.abs(arg[0]%arg[1])
    if (n1 >= 2) {
        n1 = 1
    }
    console.log(n1)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));