#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
long long n, m, s, t;
long long pos[maxn], T[maxn];
long long cal(long long x) {
  if (s < m)
    s += t;
  else
    s -= t;
  t--;
  return (s % n + n) % n;
}
int main() {
  cin >> n >> m >> s >> t;
  s--;
  while (t % n) s = cal(s);
  long long temp = t / n;
  long long tick = 0;
  while (temp--) {
    if (pos[s]) {
      temp %= tick - T[s];
      s = pos[s];
    } else {
      T[s] = tick;
      long long tmp = s;
      t = n;
      for (int i = 1; i <= n; i++) s = cal(s);
      pos[tmp] = s;
      tick++;
    }
  }
  cout << s + 1 << endl;
  return 0;
}
