#include <bits/stdc++.h>
using namespace std;
mt19937 __rand(chrono::system_clock::now().time_since_epoch().count());
struct treapnode;
struct treapnode {
  shared_ptr<treapnode> lchild, rchild;
  int val, size, height;
  long long pri;
  treapnode() {}
  treapnode(int val_, long long pri_ = __rand())
      : val(val_), size(1), height(1), pri(pri_) {}
  treapnode(int val_, const shared_ptr<treapnode>& l,
            const shared_ptr<treapnode>& r)
      : lchild(l), rchild(r), val(val_) {
    upd_size();
  }
  int get(int pos) {
    int lsize = lchild ? lchild->size : 0;
    return pos == lsize  ? val
           : pos < lsize ? lchild->get(pos)
                         : rchild->get(pos - lsize - 1);
  }
  void upd_size() {
    size = 1 + (lchild ? lchild->size : 0) + (rchild ? rchild->size : 0);
    height = 1 + max(lchild ? lchild->height : 0, rchild ? rchild->height : 0);
  }
};
int lv = 0;
shared_ptr<treapnode> join(const shared_ptr<treapnode>& u,
                           const shared_ptr<treapnode>& v) {
  ++lv;
  if (!u and !v) return nullptr;
  if (!u) return v;
  if (!v) return u;
  if ((long long)__rand() % (u->size + v->size) < (long long)u->size)
    return move(make_shared<treapnode>(u->val, u->lchild, join(u->rchild, v)));
  else
    return move(make_shared<treapnode>(v->val, join(u, v->lchild), v->rchild));
}
shared_ptr<treapnode> yank_firsthalf(const shared_ptr<treapnode>& u,
                                     int cut_size) {
  if (!u) return nullptr;
  int lsize = u->lchild ? u->lchild->size : 0;
  if (cut_size <= lsize) {
    return yank_firsthalf(u->lchild, cut_size);
  } else {
    return make_shared<treapnode>(
        u->val, u->lchild, yank_firsthalf(u->rchild, cut_size - lsize - 1));
  }
}
shared_ptr<treapnode> yank_secondhalf(const shared_ptr<treapnode>& u,
                                      int cut_size) {
  if (!u) return nullptr;
  int lsize = u->lchild ? u->lchild->size : 0;
  if (cut_size <= lsize) {
    return make_shared<treapnode>(u->val, yank_secondhalf(u->lchild, cut_size),
                                  u->rchild);
  } else {
    return yank_secondhalf(u->rchild, cut_size - lsize - 1);
  }
}
shared_ptr<treapnode> safe_slice(const shared_ptr<treapnode>& u, int offset,
                                 int size) {
  offset = (offset + u->size) % u->size;
  if (offset + size <= u->size)
    return move(yank_firsthalf(yank_secondhalf(u, offset), size));
  int lsize = u->size - offset;
  return move(
      join(yank_secondhalf(u, offset), yank_firsthalf(u, size - lsize)));
}
ostream& operator<<(ostream& cout, const shared_ptr<treapnode>& u) {
  for (int i = -1; ++i < u->size;) cout << u->get(i) << ' ';
  return cout;
}
int n, m, s;
long long t;
shared_ptr<treapnode> build(int l, int r, const function<int(int)>& get_info) {
  if (l >= r) return nullptr;
  int mid = l + (r - l) / 2;
  auto res = make_shared<treapnode>(get_info(mid));
  if (r - l <= 1) return move(res);
  res->lchild = build(l, mid, get_info);
  res->rchild = build(mid + 1, r, get_info);
  res->upd_size();
  return move(res);
}
vector<int> vals;
void tranversal(const shared_ptr<treapnode>& root) {
  if (!root) return;
  tranversal(root->lchild);
  vals.push_back(root->val);
  tranversal(root->rchild);
}
shared_ptr<treapnode> rebuild(const shared_ptr<treapnode>& root) {
  vals.clear();
  tranversal(root);
  return move(build(0, root->size, [&](int id) { return vals[id]; }));
}
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> s >> t;
  --s;
  shared_ptr<treapnode> root = build(0, n, [&](int id) { return id; });
  for (int step = 0; step++ < n - 1;) {
    lv = 0;
    root = move(
        join(safe_slice(root, step, m), safe_slice(root, m - step, n - m)));
    if (root->height > 100) {
      root = move(rebuild(root));
    }
  }
  for (int i = (int)(t % n); i > 0; i--) {
    s += (s < m ? i : -i);
    s = (s + n) % n;
  }
  vector<int> dis(n, -1);
  dis[s] = 0;
  bool reduced = 0;
  for (long long i = t / n; i--;) {
    int nxt = root->get(s);
    if (dis[nxt] == -1) {
      dis[nxt] = dis[s] + 1;
    } else if (!reduced) {
      i %= dis[s] + 1 - dis[nxt];
      reduced = 1;
    }
    s = nxt;
  }
  cout << s + 1;
  return 0;
}
