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.*;
import java.util.*;

public class C421 {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);
        int a = in.nextInt();
        int b = in.nextInt();
        int l = in.nextInt() - 1;
        int r = in.nextInt() - 1;       
        int ans;
        int len = a + b;
        int dif = r - l;
        if(dif >= 2 * len) {
            ans = Integer.max(a + 1, 2 * a - b);
        } else {
            //shift to the left
            r -= len * (l / len);
            l %= len;
            //System.out.println(l + " " + r);
            ans = numOfDifLet(a, b, l, r);
        }

        System.out.println(ans);
        
    }
    
    static int numOfDifLet(int a, int b, int l, int r) {
        int first = b < a ? b : a - 1;
        int last = a - 1;
        
        // abcd dd abef ff
        // abcd cc abef ff abcd dd abef ff
        
        StringBuilder sb = new StringBuilder();
        char ch = 'a';
        for(int i = 0; i < a; ++i) {
            sb.append(ch);
            ch++;
        }
        ch = l < a ? sb.charAt(last) : sb.charAt(first);
        for(int i = 0; i < b; ++i) {
            sb.append(ch);
        }
        boolean[] used = new boolean[30];
        for(int i = 0; i < a; ++i) {
            used[sb.charAt(sb.length() - i - 1) - 'a'] = true;
        }
        int ptr = 0;
        for(int i = 0; i < a; ++i) {
            while(used[ptr]) ptr++;
            sb.append((char)('a' + ptr));
            used[ptr] = true;
        }
        ch = sb.charAt(Integer.min(b, a - 1) + a + b);
        for(int i = 0; i < b; ++i) {
            sb.append(ch);
        }
        for(int i = 0; i < a + b; ++i) {
            sb.append(sb.charAt(i));
        }
        return numOfDifLet(sb.toString(), l, r);
    }
    
    static int numOfDifLet(String s, int l, int r) {
        boolean[] used = new boolean[30];
        for(int i = l; i <= r; ++i) {
            used[s.charAt(i) - 'a'] = true;
        }
        int ans = 0;
        for(int i = 0; i < 30; ++i) {
            if(used[i]) ans++;
        }
        return ans;
    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void printf(String format, Object... objects) {
            writer.printf(format, objects);
        }

        public void close() {
            writer.close();
        }

        public void flush() {
            writer.flush();
        }

    }
    
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (this.numChars == -1) {
                throw new InputMismatchException();
            } else {
                if (this.curChar >= this.numChars) {
                    this.curChar = 0;

                    try {
                        this.numChars = this.stream.read(this.buf);
                    } catch (IOException var2) {
                        throw new InputMismatchException();
                    }

                    if (this.numChars <= 0) {
                        return -1;
                    }
                }

                return this.buf[this.curChar++];
            }
        }

        public int nextInt() {
            int c;
            for (c = this.read(); isSpaceChar(c); c = this.read()) {
                ;
            }

            byte sgn = 1;
            if (c == 45) {
                sgn = -1;
                c = this.read();
            }

            int res = 0;

            while (c >= 48 && c <= 57) {
                res *= 10;
                res += c - 48;
                c = this.read();
                if (isSpaceChar(c)) {
                    return res * sgn;
                }
            }

            throw new InputMismatchException();
        }

        public static boolean isSpaceChar(int c) {
            return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
        }

    }
}
