#include <bits/stdc++.h>
using namespace std;
char string_in_buffer[(int)260];
void fast_scan(int &first) { scanf("%d", &first); }
void fast_scan(long long &first) { scanf("%lld", &first); }
void fast_scan(unsigned long long &first) { scanf("%llu", &first); }
void fast_scan(double &first) { scanf("%lf", &first); }
void fast_scan(long double &first) { scanf("%Lf", &first); }
void fast_scan(char &first) {
  scanf("%c", &first);
  if (first == '\n') {
    fast_scan(first);
  }
}
void fast_scan(string &first) {
  scanf("%s", string_in_buffer);
  first = string(string_in_buffer);
}
template <class TFirst, class TSecond>
void fast_scan(pair<TFirst, TSecond> &p) {
  fast_scan(p.first);
  fast_scan(p.second);
}
template <class T>
void fast_scan(vector<T> &v) {
  for (auto &first : v) fast_scan(first);
}
void fast_print(const int &first) { printf("%d", first); }
void fast_print(const unsigned int &first) { printf("%u", first); }
void fast_print(const long long &first) { printf("%lld", first); }
void fast_print(const unsigned long long &first) { printf("%llu", first); }
void fast_print(const double &first) { printf("%.15lf", first); }
void fast_print(const long double &first) { printf("%.15Lf", first); }
void fast_print(const char &first) { printf("%c", first); };
void fast_print(const string &first) { printf("%s", first.c_str()); }
void fast_print(const char v[]) { fast_print((string)v); }
template <class TFirst, class TSecond>
void fast_print(const pair<TFirst, TSecond> &p) {
  fast_print(p.first);
  fast_print(' ');
  fast_print(p.second);
}
template <class T>
void fast_print(const vector<T> &v) {
  if (v.empty()) return;
  fast_print(v[0]);
  for (int i = 1; i < v.size(); i++) {
    fast_print(' ');
    fast_print(v[i]);
  }
}
template <class T>
void fast_print(const vector<vector<T>> &v) {
  if (v.empty()) return;
  fast_print(v[0]);
  for (int i = 1; i < v.size(); i++) {
    fast_print('\n');
    fast_print(v[i]);
  }
}
template <class T>
void fast_print(const T &v) {
  for (const auto &first : v) {
    fast_print(first);
    fast_print(' ');
  }
}
using namespace std;
namespace smart_io {
string print_start = "";
string sep = " ";
bool first_print = false;
void precall_print() {
  fast_print(print_start);
  print_start = "\n";
  first_print = true;
}
void _print(deque<string>) {}
template <class T, class... Args>
void _print(deque<string> names, T elem, Args... args) {
  if (!first_print) {
    fast_print("\n");
  } else {
    first_print = false;
  }
  fast_print(names.front());
  fast_print(" = ");
  fast_print(elem);
  names.pop_front();
  _print(names, args...);
}
}  // namespace smart_io
template <class T>
ostream &operator,(ostream &os, const T &object) {
  if (!smart_io::first_print) {
    fast_print(smart_io::sep);
  } else {
    smart_io::first_print = false;
  }
  fast_print(object);
  return os;
}
template <class T>
istream &operator,(istream &is, T &object) {
  fast_scan(object);
  return is;
}
namespace typedefs {}
namespace numbers_operation {
template <class T>
T floor_mod(T a, T b) {
  if (a % b == 0) return 0;
  if (a >= 0 && b >= 0) return a % b;
  if (a <= 0 && b <= 0) return a % b;
  return abs(b) - (abs(a) % abs(b));
}
}  // namespace numbers_operation
using namespace numbers_operation;
using namespace typedefs;
mt19937 gen(1337);
namespace Flex {
struct Node {
  Node *l = NULL, *r = NULL, *junk = NULL;
  long long prior = 0;
  long long value = 0;
  long long mod_value = 0;
  vector<long long> values;
  Node(long long _value) {
    value = _value;
    values.push_back(value);
    prior = gen();
  }
};
pair<Node *, Node *> split(Node *node, long long L);
void push(Node *node);
Node *interfere(Node *a, Node *b) {
  if (!a) return b;
  if (!b) return a;
  if (gen() % 2 == 0) {
    swap(a, b);
  }
  push(a);
  a->junk = b;
  return a;
}
void push(Node *node) {
  if (!node) return;
  if (node->junk) {
    auto t = split(node->junk, node->value);
    auto t2 = split(t.second, node->value + 1);
    node->l = interfere(node->l, t.first);
    node->r = interfere(node->r, t2.second);
    node->junk = NULL;
    if (t2.first) {
      for (long long first : t2.first->values) {
        node->values.push_back(first);
      }
    }
  }
  node->value += node->mod_value;
  if (node->l) {
    node->l->mod_value += node->mod_value;
  }
  if (node->r) {
    node->r->mod_value += node->mod_value;
  }
  node->mod_value = 0;
}
Node *merge(Node *l, Node *r) {
  if (!l) return r;
  if (!r) return l;
  push(l);
  push(r);
  if (l->prior > r->prior) {
    l->r = merge(l->r, r);
    return l;
  } else {
    r->l = merge(l, r->l);
    return r;
  }
}
pair<Node *, Node *> split(Node *node, long long L) {
  if (!node) return make_pair(node, node);
  push(node);
  if (node->value >= L) {
    auto t = split(node->l, L);
    node->l = NULL;
    return make_pair(t.first, merge(t.second, node));
  } else {
    auto t = split(node->r, L);
    node->r = NULL;
    return make_pair(merge(node, t.first), t.second);
  }
}
pair<Node *, Node *> cut_segment(Node *node, long long l, long long r) {
  if (!node) return make_pair(node, node);
  push(node);
  auto t = split(node, l);
  auto t2 = split(t.second, r);
  return make_pair(merge(t.first, t2.second), t2.first);
}
Node *find(Node *node, long long value) {
  if (!node) return node;
  push(node);
  if (node->value == value) return node;
  if (value > node->value) {
    return find(node->r, value);
  } else {
    return find(node->l, value);
  }
}
};  // namespace Flex
using namespace Flex;
void printout(long long n, Node *root) {
  for (long long i = 0; i < 3 * n; i++) {
    Node *f = find(root, i);
    vector<long long> rez;
    if (f) {
      rez = f->values;
    }
    sort(rez.begin(), rez.end());
    smart_io::precall_print();
    cout, rez;
  }
}
void test() {
  long long n, q;
  cin, n, q;
  Node *root = NULL;
  for (long long i = 0; i < n; i++) {
    root = merge(root, new Node(i));
  }
  for (long long i = 0; i < (q); i++) {
    long long a, b, k;
    cin, a, b, k;
    auto t = split(root, a);
    auto t2 = split(t.second, a + k);
    if (t2.first) {
      t2.first->mod_value += b - a;
    }
    root = interfere(interfere(t.first, t2.first), t2.second);
  }
  printout(n, root);
}
namespace CircleProcessor {
vector<pair<pair<long long, long long>, pair<long long, long long>>> shift(
    long long N, long long l, long long r, long long sh) {
  sh = floor_mod(sh, N);
  r--;
  long long nl = (l + sh) % N;
  long long nr = (r + sh) % N;
  if (nr < nl) {
    long long F = N - nl;
    return {{make_pair(l, l + F), make_pair(nl, nl + F)},
            {make_pair(l + F, r + 1), make_pair(0, nr + 1)}};
  } else {
    return {{make_pair(l, r + 1), make_pair(nl, nr + 1)}};
  }
}
};  // namespace CircleProcessor
vector<long long> g;
vector<vector<long long>> mem;
long long predict(long long v, long long k) {
  if (mem[v][k] != -1) return mem[v][k];
  if (k == 0) {
    return g[v];
  } else {
    return mem[v][k] = predict(predict(v, k - 1), k - 1);
  }
}
long long go(long long v, long long m) {
  for (long long k = 19; k > -1; k--) {
    while ((1 << k) <= m) {
      v = predict(v, k);
      m -= (1 << k);
    }
  }
  assert(m == 0);
  return v;
}
signed main(signed argc, char *argv[]) {
  long long n, m;
  cin, n, m;
  mem.resize(n, vector<long long>(20, -1));
  long long s, t;
  cin, s, t;
  s--;
  Node *root = NULL;
  for (long long i = 0; i < n; i++) {
    root = merge(root, new Node(i));
  }
  for (long long i = t; i > t - n; i--) {
    vector<Node *> parts;
    auto t = split(root, m);
    for (auto first : CircleProcessor::shift(n, 0, m, i)) {
      Node *seg = NULL;
      tie(t.first, seg) =
          cut_segment(t.first, first.first.first, first.first.second);
      if (seg) {
        seg->mod_value += first.second.first - first.first.first;
      }
      parts.emplace_back(seg);
    }
    for (auto first : CircleProcessor::shift(n, m, n, -i)) {
      Node *seg = NULL;
      tie(t.second, seg) =
          cut_segment(t.second, first.first.first, first.first.second);
      if (seg) {
        seg->mod_value += first.second.first - first.first.first;
      }
      parts.emplace_back(seg);
    }
    root = NULL;
    for (Node *part : parts) {
      root = interfere(root, part);
    }
  }
  g.resize(n);
  for (long long i = 0; i < n; i++) {
    Node *node = find(root, i);
    if (node) {
      for (long long first : node->values) {
        g[first] = i;
      }
    }
  }
  long long cnt = t / n;
  s = go(s, cnt);
  long long final = t % n;
  for (long long i = final; i > -1; i--) {
    if (s < m) {
      s = (s + i) % n;
    } else {
      s = floor_mod(s - i, n);
    }
  }
  smart_io::precall_print();
  cout, s + 1;
}
