public static int HotPotato(int n, int time) {
int full = time / (n - 1);
int extra = time % (n - 1);
int direction = full % 2 == 0 ? 1 : -1;
return direction == 1 ? extra + 1 : n - extra;
public static void Main()
Console.WriteLine("UniLecs");
Console.WriteLine(HotPotato(4, 5).ToString());
Console.WriteLine(HotPotato(3, 2).ToString());