const lines = require('fs') .readFileSync('/dev/stdin', 'utf-8') .trim().split('\n').values(); let W = Number(lines.next().value); let D = Number(lines.next().value); while (D > 1) { W -= Math.floor(W / (D ** 2)); D--; } console.log(W);