#include <bits/stdc++.h>
const int MAXN = 100011;
int N, M;
int S;
long long T;
long long Tim[MAXN];
int Nxt(int Pos) {
  long long ret = (long long)(Pos);
  ret += (Pos < M) ? T : (-T);
  --T;
  return ((int)(ret % (long long)(N)) + N) % N;
}
int main() {
  scanf("%d%d%d%I64d", &N, &M, &S, &T);
  --S;
  while (true) {
    if (Tim[S]) T %= (Tim[S] - T);
    Tim[S] = T;
    if (T <= N) {
      while (T) S = Nxt(S);
      printf("%d\n", S + 1);
      return 0;
    }
    for (int i = 0; i < N; ++i) S = Nxt(S);
  }
  return 0;
}
