#include <bits/stdc++.h>   using namespace std;   long long tree[1000001];   int n;   void update(int x, long long val) {     for (int i = x; i <= n; i += i & (-i)) {       tree[i] += val;     }   }   long long query(int x) {     long long sum = 0;     while (x > 0) {       sum += tree[x];       x -= x & (-x);     }     return sum;   }   int main() {     int m, i, j = 2, k;     long long l = 1;     cin >> n >> k;     m = 0;     int count = 0;     i = 1;     while (count < n) {       j = (i + k) % n;       if (!j) j = n;       m = i % n;       if (!m) m = n;       if (m > j) {         l += min(query(j - 1) + query(n) - query(m), query(m - 1) - query(j)) +              (long long)1;       } else {         l += min(query(j) - query(m), query(m - 1) + query(n) - query(j)) +              (long long)1;       }       cout << l <<    ;       update(m, 1);       update(j, 1);       count++;       i = j;     }     return 0;   }   