#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long Inf = 1e18;
const int N = 1e5 + 10;
const int mod = 0;
long long gi() {
  long long x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
template <typename T>
bool chkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
};
template <typename T>
bool chkmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
};
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
void inc(int &a, int b) { a = (a + b >= mod ? a + b - mod : a + b); }
void dec(int &a, int b) { a = (a - b < 0 ? a - b + mod : a - b); }
int n, m, s;
long long t, vis[N];
int main() {
  n = gi(), m = gi(), s = gi() - 1, t = gi();
  while (t % n) {
    if (s < m)
      s = (s + t % n) % n;
    else
      s = (s - t % n + n) % n;
    --t;
  }
  memset(vis, -1, sizeof(vis));
  vis[s] = t, t /= n;
  while (t--) {
    for (int i = n - 1; ~i; i--) {
      if (s < m)
        s = (s + i % n) % n;
      else
        s = (s - i % n + n) % n;
    }
    if (~vis[s]) t %= vis[s] - t;
    vis[s] = t;
  }
  printf("%d\n", s + 1);
  return 0;
}
