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

int main() {
    int n, k, m;
    cin >> n >> k >> m;
    
    vector<int> people(n);
    for (int i = 0; i < n; ++i) {
        people[i] = i;  // 初始化人员编号0~n-1
    }
    
    int current = k;  // 从编号k开始报数
    
    while (people.size() > 1) {
        // 计算需要移除的人的索引
        int remove_idx = (current + m - 1) % people.size();
        /*报数是环形的,超过数组长度需要从头开始。
        % circle.size() 实现循环索引。*/


        // 移除该人
        people.erase(people.begin() + remove_idx);
        
        // 更新下一轮开始的位置
        if (people.size() > 0) {
            current = remove_idx % people.size();
        }
    }
    
    cout << people[0] << endl;  // 输出最后剩下的大王编号
    return 0;
}

经典!!