Codeforces Beta Round 62
A
Irrational problem
Codeforces
1100
原题
←B →
翻译中…

Little Petya was given this problem for homework:

翻译中…

You are given function image (here image 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 image 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.

翻译中…

样例

Input #1
2 7 1 8 2 8
Output #1
0
InputCopy OutputCopy
Input #2
20 30 40 50 0 100
Output #2
20
InputCopy OutputCopy
Input #3
31 41 59 26 17 43
Output #3
9
InputCopy OutputCopy
题目信息
题号
68A
时间限制
2 s
内存限制
256 MB
标签
模拟
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。