#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>

typedef long long ll;
using namespace std;

#define mod 1000000009
#define INF 10000000
#define LLINF 2000000000000000000LL

#define SIZE 10001


int main(){
    int n,k;
    int s,b=0;
    int f = true;
    scanf("%d%d",&n,&k);
    
    int a = (n-1)%(k+1);
    
    while(1){
        
        if(f && a==0){
            cout << 0 << endl;
        }else{
            cout << a+(k+1) << endl;
        }
        
        scanf("%d",&b);
        
        f = false;
        if(b>n) break;
    }
    
    return 0;
}