#include #include int main(void){ int i,n,d,now=0,cnt=0; scanf("%d %d",&n,&d); int* flag; flag = (int*)malloc(sizeof(int)*n); for(i=1;i= d) now += d; else now = d-n+now; if(flag[now] == 0) flag[now] = 1; else break; cnt++; } printf("%d\n",cnt); return 0; }