#include <bits/stdc++.h>
using namespace std;
bool home = 1;
signed realMain();
signed main() {
  home = 0;
  if (home) {
    freopen("tony_stark", "r", stdin);
  } else {
    ios::sync_with_stdio(0);
    cin.tie(0);
  }
  realMain();
}
const long long N = (long long)1e5 + 7;
long long cand[N];
signed realMain() {
  long long n, m, x, t;
  cin >> n >> m >> x >> t;
  x--;
inf:
  if (cand[x]) t = t % (cand[x] - t);
  cand[x] = t;
  if (t > n) {
    for (long long i = 1; i <= n; i++) {
      if (x < m)
        x += t;
      else
        x -= t;
      t--;
      x %= n;
      if (x < 0) x += n;
    };
    goto inf;
  } else {
    while (t) {
      if (x < m)
        x += t;
      else
        x -= t;
      t--;
      x %= n;
      if (x < 0) x += n;
    };
    cout << x + 1 << "\n";
  }
  return 0;
}
