# frozen_string_literal: true def solve N <= D ? 0 : (N.lcm(D) - 1) / D end N, D = gets.split.map(&:to_i) puts solve