#include<iostream>
#include<vector>
using namespace std;

int main(){
    int total, step;
    vector<int> person;
    vector<int>::iterator it;
    int i, m;

    while(1){
        //get input
        cin >> total >> step;

        //finish condition
        if(total == 0 && step == 0) break;

        //init
        for(i = 1; i <= total; i++){
            person.push_back(i);
        }
        it = person.begin();
        
        while(1){
            //answer
            if(person.size() == 1){
                cout << person[0] <<endl;
                person.clear();
                break;
            }

            //step forward
            for(m = 0; m < (step - 1); m++){
                it++;                
                if(it == person.end()){
                    it = person.begin();
                }
            }

            //delete
            person.erase(it);
            if(it == person.end()){
                it = person.begin();
            }

            for(int k = 0; k < person.size(); k++){
                cout << *it <<"is erased " << person[k] << endl;
            }
        }
    }

    return 0;
}