#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int a, b, l, r;
  cin >> a >> b >> l >> r;
  {
    int period = a + b;
    int res;
    int start = l / period * period - 10 * period;
    if (start < 0) start = 0;
    l--;
    r--;
    l -= start;
    r -= start;
    if (r >= l + 500) {
      r = l + 500;
    }
    char s[1000];
    int lastSend[26], lastTime = 7;
    for (int i = 0; i < 26; i++) lastSend[i] = 0;
    for (int i = 0; i + period < 1000; i += period) {
      for (int j = 0, c = 0; j < a; j++) {
        while (lastSend[c] == lastTime) c++;
        s[i + j] = c++;
      }
      for (int j = a; j < period; j++) {
        s[i + j] = s[min(i + a - 1, i + period - a)];
      }
      lastTime++;
      for (int j = period - a; j < period; j++) {
        lastSend[s[i + j]] = lastTime;
      }
    }
    lastTime++;
    res = 0;
    for (int i = l; i <= r; i++) {
      if (lastSend[s[i]] != lastTime) {
        res++;
        lastSend[s[i]] = lastTime;
      }
    }
    lastTime++;
    for (int i = 0; i + period < 1000; i += period) {
      for (int j = 0, c = 0; j < a; j++) {
        while (lastSend[c] == lastTime) c++;
        s[i + j] = c++;
      }
      for (int j = a; j < period; j++) {
        s[i + j] = s[i + a - 1];
      }
      lastTime++;
      for (int j = period - a; j < period; j++) {
        lastSend[s[i + j]] = lastTime;
      }
    }
    lastTime++;
    int res2 = 0;
    for (int i = l; i <= r; i++) {
      if (lastSend[s[i]] != lastTime) {
        res2++;
        lastSend[s[i]] = lastTime;
      }
    }
    cout << min(res, res2) << endl;
  }
}
