#include <stdio.h>
int main()
{
int a,b,c,d,z;
scanf("%d %d",&a,&b);
scanf("%d",&c);
d=b+c;
z=d/60;
if(d<60)
{
printf("%d %d",a,d);
}
else
{
if(a+z>=24)
{
a=a-24;
}
printf("%d %d",a+z,d%60);
}
}
0
2.5
3.5
0
2
*/
#include <stdio.h>
int main()
{
double s,e,y,sum=0;
int i,j;
for(i=1; i<=5; i++)
{
scanf("%lf %lf",&s,&e);
y=e-s;
if(y>1&&y<5)
{
sum=sum+y-1;
}
else if(y>=5)
{
sum=sum+4;
}
}
//printf("%lf",sum);
if(sum<=5)
{
sum=sum+sum*0.05;
}
else if(sum>=15)
{
sum=sum-sum*0.05;
}
sum=sum/0.5*5000;
printf("%d",(int)sum);
}