#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100002;
int n, m, s;
int64_t t;
bool visited[MAX_N];
void read_input() {
  cin >> n >> m >> s >> t;
  s = (s - 1 + n) % n;
}
int next_station(int s) {
  for (int t = n - 1; t >= 0; --t) {
    if (s < m)
      s = (s + t) % n;
    else
      s = (s - t + n) % n;
  }
  return s;
}
void solve() {
  while (t % n) {
    if (s < m)
      s = (s + t % n) % n;
    else
      s = (s - t % n + n) % n;
    --t;
  }
  visited[s] = true;
  vector<int> p(1, s);
  int64_t tmp = t / n;
  while (tmp > 0) {
    int s2 = next_station(s);
    if (visited[s2]) {
      for (int i = 0; i < p.size(); ++i) {
        if (p[i] == s2) {
          p.erase(p.begin(), p.begin() + i);
          break;
        }
      }
      break;
    }
    --tmp;
    visited[s2] = true;
    p.push_back(s2);
    s = s2;
  }
  if (tmp == 0)
    cout << p.back() + 1;
  else
    cout << p[(tmp % p.size() - 1 + p.size()) % p.size()] + 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  read_input();
  solve();
}
