#include <bits/stdc++.h>
using namespace std;
int N, M, B;
int S;
signed long long T;
vector<int> hist;
int vis[303030];
int nex(int S, signed long long T) {
  if (S < M)
    S += T % N;
  else
    S += N - T % N;
  return S % N;
}
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N >> M;
  B = N - M;
  cin >> S >> T;
  S--;
  while (T % N) S = nex(S, T), T--;
  T /= N;
  memset(vis, 0xff, sizeof(vis));
  for (i = 0; i < (T); i++) {
    if (vis[S] != -1) {
      int per = i - vis[S];
      S = hist[vis[S] + (T - i) % per];
      break;
    }
    vis[S] = i;
    hist.push_back(S);
    for (j = N - 1; j >= 0; j--) S = nex(S, j);
  }
  cout << (S + 1) << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
