Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

A. Irrational problem

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputLittle Petya was given this problem for homework:

You are given function (here represents the operation of taking the remainder). His task is to count the number of integers *x* in range [*a*;*b*] with property *f*(*x*) = *x*.

It is a pity that Petya forgot the order in which the remainders should be taken and wrote down only 4 numbers. Each of 24 possible orders of taking the remainder has equal probability of being chosen. For example, if Petya has numbers 1, 2, 3, 4 then he can take remainders in that order or first take remainder modulo 4, then modulo 2, 3, 1. There also are 22 other permutations of these numbers that represent orders in which remainder can be taken. In this problem 4 numbers wrote down by Petya will be pairwise distinct.

Now it is impossible for Petya to complete the task given by teacher but just for fun he decided to find the number of integers with property that probability that *f*(*x*) = *x* is not less than 31.4159265352718281828459045%. In other words, Petya will pick up the number *x* if there exist at least 7 permutations of numbers *p*_{1}, *p*_{2}, *p*_{3}, *p*_{4}, for which *f*(*x*) = *x*.

Input

First line of the input will contain 6 integers, separated by spaces: *p*_{1}, *p*_{2}, *p*_{3}, *p*_{4}, *a*, *b* (1 ≤ *p*_{1}, *p*_{2}, *p*_{3}, *p*_{4} ≤ 1000, 0 ≤ *a* ≤ *b* ≤ 31415).

It is guaranteed that numbers *p*_{1}, *p*_{2}, *p*_{3}, *p*_{4} will be pairwise distinct.

Output

Output the number of integers in the given range that have the given property.

Examples

Input

2 7 1 8 2 8

Output

0

Input

20 30 40 50 0 100

Output

20

Input

31 41 59 26 17 43

Output

9

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Mar/20/2018 16:27:44 (d2).

Desktop version, switch to mobile version.

User lists

Name |
---|