Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.

All characters in this game are lowercase English letters. There are two players: Mister B and his competitor.

Initially the players have a string s consisting of the first a English letters in alphabetical order (for example, if a = 5, then s equals to "abcde").

The players take turns appending letters to string s. Mister B moves first.

Mister B must append exactly b letters on each his move. He can arbitrary choose these letters. His opponent adds exactly a letters on each move.

Mister B quickly understood that his opponent was just a computer that used a simple algorithm. The computer on each turn considers the suffix of string s of length a and generates a string t of length a such that all letters in the string t are distinct and don't appear in the considered suffix. From multiple variants of t lexicographically minimal is chosen (if a = 4 and the suffix is "bfdd", the computer chooses string t equal to "aceg"). After that the chosen string t is appended to the end of s.

Mister B soon found the game boring and came up with the following question: what can be the minimum possible number of different letters in string s on the segment between positions l and r, inclusive. Letters of string s are numerated starting from 1.

Input

First and only line contains four space-separated integers: a, b, l and r (1 ≤ a, b ≤ 12, 1 ≤ l ≤ r ≤ 109) — the numbers of letters each player appends and the bounds of the segment.

Output

Print one integer — the minimum possible number of different letters in the segment from position l to position r, inclusive, in string s.

Examples

Input

1 1 1 8


Output

2

Input

4 2 2 6


Output

3

Input

3 7 4 6


Output

1

Note

In the first sample test one of optimal strategies generate string s = "abababab...", that's why answer is 2.

In the second sample test string s = "abcdbcaefg..." can be obtained, chosen segment will look like "bcdbc", that's why answer is 3.

In the third sample test string s = "abczzzacad..." can be obtained, chosen, segment will look like "zzz", that's why answer is 1.
#include <bits/stdc++.h>
using namespace std;
void read(vector<long long>& c, long long size) {
  for (int i = 0; i < size; i++) {
    int q;
    scanf("%d", &q);
    c.push_back(q);
  }
}
void read(vector<pair<long long, long long> >& c, long long size) {
  for (int i = 0; i < size; i++) {
    int q;
    int r;
    scanf("%d", &q);
    scanf("%d", &r);
    c.push_back(make_pair(q, r));
  }
}
void print(vector<long long>& coeffs) {
  for (int i = 0; i < coeffs.size(); i++) {
    cout << coeffs[i] << " ";
  }
  cout << endl;
}
long long op(long long a, long long b, int& l) {
  if (l % 2 == 0) {
    l++;
    return a + b;
  }
  if (l % 2 == 1) {
    l++;
    return a - b;
  }
}
long long power(long long a, long long b, long long M) {
  if (b == 0) {
    return 1;
  } else {
    long long q = power(a, b / 2, M);
    long long r = (q * q) % M;
    if (b % 2) {
      return (r * a) % M;
    } else {
      return r;
    }
  }
}
long long inv(long long a, long long M) { return power(a, M - 2, M); }
bool input() {
  string q;
  cin >> q;
  return (q == "TAK");
}
int print(long long q, long long l, long long r) {
  cout << q << " " << l << " " << r << endl;
  fflush(stdout);
  if (q == 1) {
    return input();
  }
  return -1;
}
long long bs(long long l, long long r) {
  while (l < r) {
    long long mid = (l + r) / 2;
    int q = print(1, mid, mid + 1);
    if (q == 1) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  return l;
}
long long gcd(long long a, long long b) {
  if (a < b) {
    return gcd(b, a);
  }
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long M = 300007;
vector<vector<long long> > mul(vector<vector<long long> >& a,
                               vector<vector<long long> >& b, long long c) {
  vector<vector<long long> > w(c + 1, vector<long long>(c + 1, 0));
  long long i, j, k;
  for (i = 0; i <= c; i++) {
    for (j = 0; j <= c; j++) {
      for (k = 0; k <= c; k++) {
        long long p = (a[i][k] * b[k][j]) % 1000000007;
        w[i][j] = (w[i][j] + p) % 1000000007;
      }
    }
  }
  return w;
}
void mul2(vector<vector<long long> >& a, long long* p, long long c) {
  long long w[16];
  long long i, j;
  for (i = 0; i <= c; i++) {
    w[i] = 0;
    for (j = 0; j <= c; j++) {
      long long e = (a[i][j] * p[j]) % 1000000007;
      w[i] = (w[i] + e) % 1000000007;
    }
  }
  for (i = 0; i <= c; i++) {
    p[i] = w[i];
  }
}
vector<vector<long long> > power(vector<vector<long long> >& q, long long n,
                                 long long c) {
  if (n == 1) {
    auto c = q;
    return c;
  }
  auto w = power(q, n / 2, c);
  auto w1 = mul(w, w, c);
  if (n % 2) {
    return mul(w1, q, c);
  } else {
    return w1;
  }
}
int main() {
  long long m, n, k, d;
  long long f;
  long long l, r, q;
  long long i, j;
  long long c, v0, v1;
  long long a, b;
  cin >> a >> b >> l >> r;
  long long sz = INT_MAX;
  long long r2;
  r--;
  l--;
  for (q = 1; q <= max(1LL, a - b); q++) {
    for (r2 = 1; r2 <= max(1LL, a - b); r2++) {
      string s;
      for (i = 0; i < a; i++) {
        s.append(1, 'a' + i);
      }
      s.append(b, 'a' + i - q);
      for (j = 0; j < a; j++) {
        if (j == a - 1) {
          s.append(1, 'a' + i);
          i++;
          break;
        }
        if (j < b) {
          s.append(1, 'a' + j);
        } else {
          s.append(1, 'a' + i);
          i++;
        }
      }
      s.append(b, 'a' + i - r2);
      set<char> w;
      for (i = 0; i < s.size(); i++) {
        w.insert(s[i]);
      }
      if (r - l >= 2 * a + 2 * b) {
        cout << w.size() << endl;
        return 0;
      }
      long long r1 = r % (2 * a + 2 * b);
      long long l1 = l % (2 * a + 2 * b);
      set<char> ww;
      if (l1 <= r1) {
        for (i = l1; i <= r1; i++) {
          ww.insert(s[i]);
        }
        sz = min(sz, (long long)ww.size());
      } else {
        for (i = l1; i < s.size(); i++) {
          ww.insert(s[i]);
        }
        for (i = 0; i <= r1; i++) {
          ww.insert(s[i]);
        }
        sz = min(sz, (long long)ww.size());
      }
    }
  }
  cout << sz << endl;
}
