import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N = sc.nextInt(); long D = sc.nextInt(); long ans = 0; for(int i = 1; ; i++) { if((N * i) % D == 0) { ans = (N * i) / D - 1; break; } } System.out.println(ans); } }