class Solution {
public:
    int LastRemaining_Solution(int n, int m) {
        if(n==1){
            return 0;
        }
        return (m+LastRemaining_Solution(n-1, m))%n;
    }
};