#include<stdio.h>
#include<stdlib.h>
int main()
{
	int p ,q ,r,lp,lq,lr,i;
	long long int R,L,Lp,Lq,Lr;
	scanf("%d%d%d",&p,&q,&r);
	scanf("%lld%lld",&L,&R);
	Lp=L/p;
	Lq=L/q;
	Lr=L/r;
	lp=L%p;
	lq=L%q;
	lr=L%r;
	if(lp!=0)
	Lp++;
	else
	lp=p;
	if(lq!=0)
	Lq++;
	else
	lq=q;
	if(lr!=0)
	Lr++;
	else
	lr=r;
	int k=0,s=0;
	for(i=L;i<=R;i++)
	{
      s=Lp+Lr+Lq;
	  if(s<=i)
	  k++;
	  lp++;
	  lq++;
	  lr++;
	  if(lp>p)
	  { Lp++; lp=1;	}
	  if(lq>q)
	  { Lq++; lq=1;	}
	  if(lr>r)
	  { Lr++; lr=1;	}		
	}
	printf("%d",k);

}