#include using namespace std; int a[250000000]; int main(void) { int N, D, count = 0; cin.tie(0); cin >> N >> D; a[0] = a[1] = 1; for (int i = 1+D;; i+=D) { if (i <= N) { if(!a[i]) { count++; a[i] = 1; } else { break; } } else { i-=N; if(!a[i]) { count++; a[i] = 1; } else { break; } } } cout <