#include <bits/stdc++.h>
using namespace std;
int nextt[100001];
unordered_map<int, long long> M(100001);
int calc_ns(int s, long long t, int m, int n) {
  if (s < m) return (s + (t % n)) % n;
  return (s - (t % n) + n) % n;
}
int add(long long a, long long b, int n) { return (a + b) % n; }
int df(long long a, long long b, int n) { return ((a - b) % n + n) % n; }
int main() {
  int n, m;
  int s;
  long long t;
  scanf("%d %d", &n, &m);
  scanf("%d %lld", &s, &t);
  s--;
  while (t % n != 0) {
    s = calc_ns(s, t, m, n);
    t--;
  }
  memset(nextt, -1, sizeof(nextt));
  while (t > 0) {
    auto it = M.find(s);
    if (it != M.end()) {
      long long d = it->second - t;
      if (t >= d) {
        t %= d;
        continue;
      }
    }
    M[s] = t;
    if (nextt[s] != -1) {
      s = nextt[s];
      t -= n;
      continue;
    }
    int ns = s;
    t--;
    while (t % n != 0) {
      ns = calc_ns(ns, t, m, n);
      t--;
    }
    nextt[s] = ns;
    s = ns;
  }
  printf("%d\n", s + 1);
  return 0;
}
