#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:512000000")
using namespace std;
using li = long long;
using ld = long double;
void solve(bool);
void precalc();
clock_t start;
int main() {
  start = clock();
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  precalc();
  while (t--) {
    solve(true);
  }
  cout.flush();
  return 0;
}
template <typename T>
T binpow(T q, T w, T mod) {
  if (!w) return 1 % mod;
  if (w & 1) return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}
template <typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template <typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}
template <typename T>
void make_unique(vector<T>& vec) {
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
}
template <typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}
template <typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}
mt19937 rng(
    (unsigned long long)chrono::steady_clock::now().time_since_epoch().count());
void precalc() {}
void solve(__attribute__((unused)) bool read) {
  li n, m;
  li s, t;
  if (read) {
    cin >> n >> m;
    cin >> s >> t;
    --s;
  } else {
    n = rand() % 100000 + 3;
    m = rand() % (n - 1) + 1;
    s = rand() % n;
    t = (rand() * (1LL << 32) + rand()) % 1000000000000LL + 1;
  }
  auto make_move = [&]() {
    li shift = t % n;
    if (s >= m) {
      shift = (n - shift) % n;
    }
    s = (s + shift) % n;
    --t;
  };
  vector<li> gone(n, -1);
  while (t % n) {
    make_move();
  }
  li iters = 0;
  vector<li> used_time(n, -1);
  li cycle = -1;
  while (t > 0) {
    li cur = s;
    if (gone[cur] != -1) {
      if (cycle == -1) {
        cycle = used_time[cur] - t;
        t %= cycle;
      } else {
        t -= n;
        s = gone[cur];
      }
      continue;
    }
    used_time[cur] = t;
    ++iters;
    for (li i = 0; i < n; ++i) {
      make_move();
    }
    gone[cur] = s;
  }
  cout << s + 1 << endl;
}
