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.
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.InputMismatchException;

public class C421 {

	InputStream is;
	PrintWriter out;
	int n;
	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	int a;
	int b;

	void solve() {
		a = ni();
		b = ni();
		int l = ni();
		int r = ni();
		StringBuilder s = new StringBuilder();
		HashSet<Character> hs = new HashSet<>();
		HashSet<Character> A = new HashSet<>();
		for (int i = 0; i < a; i++) {
			s.append((char) ('a' + i));

		}
		for (int i = 0; i < b; i++) {
			s.append((char) ('a' + a - 1));
		}
		for (int i = s.length() - 1; i >= s.length() - a; i--) {
			hs.add(s.charAt(i));
		}
		int temp = a;
		for (int i = 0; i < 26; i++) {
			if (!hs.contains((char) ('a' + i))) {
				temp--;
				s.append((char) ('a' + i));
				if (temp == 0)
					break;
			}
		}
		char c = s.charAt(s.length() - 1);
		for (int i = 0; i < b; i++) {
			s.append(c);
		}
		for (int i = 0; i < s.length(); i++) {
			A.add(s.charAt(i));
		}
		if ((r - l) / (2 * (a + b)) >= 1) {
			// out.println("hi");
			out.println(A.size());
		} else {
			l = l % (2 * (a + b));
			r = r % (2 * (a + b));
			// out.println(l + " " + r);
			if (l == 0)
				l = 2 * (a + b);
			if (r == 0)
				r = 2 * (a + b);
			int min = Integer.MAX_VALUE;
			for (int i = b; i < a; i++) {
				for (int j = b + b + a; j < 2 * a + b; j++) {
					min = Math.min(min, check(s.charAt(i) - 'a', s.charAt(j) - 'a', l, r));
				}
			}
			if (a <= b) {
				min = Math.min(min, check(s.charAt(a - 1) - 'a', s.charAt(a + a + b - 1) - 'a', l, r));
			}
			out.println(min);
		}

	}

	int check(int x, int y, int l, int r) {
		int ans = 0;
		StringBuilder s = new StringBuilder();
		HashSet<Character> hs = new HashSet<>();
		for (int i = 0; i < a; i++) {
			s.append((char) (i + 'a'));

		}
		for (int i = 0; i < b; i++) {
			s.append((char) (x + 'a'));
		}
		for (int i = s.length() - 1; i >= s.length() - a; i--) {
			hs.add(s.charAt(i));
		}
		int temp = a;
		for (int i = 0; i < 26; i++) {
			if (!hs.contains((char) ('a' + i))) {
				temp--;
				s.append((char) ('a' + i));
				if (temp == 0)
					break;
			}
		}
		for (int i = 0; i < b; i++) {
			s.append((char) ('a' + y));
		}
		HashSet<Character> set = new HashSet<>();
		if (l <= r) {
			for (int i = l - 1; i < r; i++) {
				set.add(s.charAt(i));
			}
		} else {
			for (int i = l - 1; i < s.length(); i++) {
				set.add(s.charAt(i));
			}
			for (int i = 0; i < r; i++) {
				set.add(s.charAt(i));
			}

		}
		ans = set.size();
		// out.println(ans + " xx " + s);
		return ans;
	}

	void run() throws Exception {
		String INPUT = "C:\\Users\\Admin\\Desktop\\input.txt";
		is = oj ? System.in : new FileInputStream(INPUT);
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					new C421().run();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}

}
