#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:167772160000")
using namespace std;
void redirectIO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
}
long long been[110000];
int solve(int nn, int mm, int ss, long long tt) {
  for (int i = 0; i < (nn + 5); i++) been[i] = 0;
  int n, m;
  n = nn;
  m = mm;
  int s;
  s = ss;
  s--;
  long long t;
  t = tt;
  while (t % n != 0) {
    int move = t % n;
    if (s < m)
      s += move;
    else
      s -= move;
    s = (s % n + n) % n;
    t--;
  }
  long long times = t / n;
  while (times > 0) {
    if (been[s]) {
      times %= (been[s] - times);
      break;
    }
    been[s] = times;
    for (int i = n - 1; i > 0; i--) {
      if (s < m)
        s += i;
      else
        s -= i;
      if (s < 0)
        s += n;
      else if (s >= n)
        s -= n;
    }
    times--;
  }
  if (times != 0) {
    int i = 0;
    while (been[i] == 0 || been[s] - been[i] != times) i++;
    s = i;
    times = 0;
  }
  return s + 1;
}
int main() {
  redirectIO();
  int nn, mm, ss;
  long long tt;
  cin >> nn >> mm >> ss >> tt;
  cout << solve(nn, mm, ss, tt) << endl;
  return 0;
}
