'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const n = parseInt(args[0][0], 10)
	const k = parseInt(args[0][1], 10)

	const t1 = Math.floor(n / k)
	const t2 = n % k
	console.log( Math.abs(t1 - (t1 + t2)) )
}

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