Time Lapse :11min 23sec 1188.cpp12345678910111213#include <iostream>using namespace std;int n, m;int gcd(int p, int q){ return q ? gcd(q, p%q) : p;}int main(void) { scanf("%d %d", &n, &m); int g = gcd(n, m); m /= g; cout<<(m - 1) * g;}