java sol
Code

# Code
```java []
class Solution {
    public int numberOfChild(int n, int k) {
        int x = k;
        if(k>=n){
            x = k % (2*n - 2);
            if(x>=n){
                x = n-1 - (x%(n-1));
                // x = x - x%(n-1) * 2;
            }
        }
        return x;
    }
}
```
['Java']