#include <bits/stdc++.h>
using namespace std;
const int MAX = 100000 + 5;
int n, m, pos;
inline int nxt(int first, int d) {
  if (first <= m)
    return (first + d) % n;
  else
    first -= d;
  if (first < 0)
    return first + n;
  else
    return first;
}
int bio[MAX];
int fst[MAX];
int tajm = 0;
int calc(int st, long long t) {
  if (bio[st] >= 0) return bio[st];
  fst[st] = tajm;
  int _st = st;
  while (t) {
    st = nxt(st, t % n);
    t--;
  }
  return bio[_st] = st;
}
void END(long long first) {
  printf("%lld\n", first + 1);
  exit(0);
}
int main() {
  long long t;
  scanf("%d%d", &n, &m);
  m--;
  scanf("%d%lld", &pos, &t);
  pos--;
  while (t % n) {
    pos = nxt(pos, t % n);
    t--;
  }
  for (int i = (0), _for = (n); i < _for; ++i) bio[i] = -1;
  t /= n;
  tajm = t;
  while (t) {
    if (bio[pos] >= 0) {
      t %= (fst[pos] - tajm);
      goto qwe;
    }
    pos = calc(pos, n);
    t--;
    tajm--;
  }
qwe:;
  while (t) {
    pos = calc(pos, n);
    t--;
  }
  END(pos);
  return 0;
}
