#include <bits/stdc++.h>
using namespace std;
uint64_t rnd_data = 0xDEADBEEFDULL;
inline void my_srand(int seed) { rnd_data = ((uint64_t)seed << 16) | 0x330E; }
inline int my_rand() {
  rnd_data = rnd_data * 0x5DEECE66DULL + 0xB;
  return (rnd_data >> 17) & 0x7FFFFFFF;
}
template <typename T>
void my_random_shuffle(T b, T e) {
  for (int i = (1); i <= (int)((int)(e - b) - 1); i++) {
    swap(b[i], b[my_rand() % (i + 1)]);
  }
}
template <class _T>
inline _T sqr(const _T &x) {
  return x * x;
}
template <typename type_t, typename less_t = std::less<type_t>>
inline bool uin(type_t &a, const type_t &b, const less_t &ls = less_t()) {
  return ls(b, a) ? a = b, true : false;
}
template <typename type_t, typename less_t = std::less<type_t>>
inline bool uax(type_t &a, const type_t &b, const less_t &ls = less_t()) {
  return ls(a, b) ? a = b, true : false;
}
const long double PI = 3.1415926535897932384626433832795L;
const long double EPS = 1e-9;
int n, m, s;
long long t;
long long d[102400];
int go(int x, int l) {
  if (x < m)
    return (x + l) % n;
  else
    return (x - l + n) % n;
}
int main() {
  cin >> n >> m >> s >> t;
  s--;
  int x = s;
  while (t % n) {
    x = go(x, t % n);
    t--;
  }
  memset(d, 0xff, sizeof(d));
  while (t) {
    long long cur = t / n;
    if (d[x] >= 0) {
      long long prev = d[x];
      long long len = (prev - cur) * n;
      t %= len;
    }
    if (!t) break;
    d[x] = cur;
    for (int i = 0; i < (int)(n); i++) {
      x = go(x, t % n);
      t--;
    }
  }
  printf("%d\n", x + 1);
  return 0;
}
