#include<iostream>
#include<cstdio>
#define lon unsigned long long
using namespace std;
lon n1,y1,r1,s1,f1,m1;
lon n2,y2,r2,s2,f2,m2;
lon ans,month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool judge(lon n)
{
if((n%4==0&&n%100!=0)||n%400==0)
return 1;
return 0;
}
lon yue(lon n,lon y)
{
lon tmp=0;
if(judge(n)) month[2]=29;
else month[2]=28;
for(lon i=1;i<y;i++)
tmp+=month[i]*24*60*60;
return tmp;
}
lon nian(lon n)
{
lon tmp=0;
if(judge(n))
tmp=366*24*60*60;
else tmp=365*24*60*60;
return tmp;
}
void work()
{
if(n1==n2)
{
if(y1==y2)
{
if(r1==r2)
{
if(s1==s2)
{
if(f1==f2)
{
if(m1==m2)
ans+=0;
else ans=m2-m1;
}
else
{
lon t1=f1*60+m1;
lon t2=f2*60+m2;
ans=t2-t1;
}
}
else
{
lon t1=s1*60*60+f1*60+m1;
lon t2=s2*60*60+f2*60+m2;
ans=t2-t1;
}
}
else
{
lon t1=(r1-1)*24*60*60+s1*60*60+f1*60+m1;
lon t2=(r2-1)*24*60*60+s2*60*60+f2*60+m2;
ans=t2-t1;
}
}
else
{
lon t1=0,t2=0;
t1+=yue(n1,y1);
t1+=(r1-1)*24*60*60+s1*60*60+f1*60+m1;
t2+=yue(n2,y2);
t2+=(r2-1)*24*60*60+s2*60*60+f2*60+m2;
ans=t2-t1;
}
}
else
{
lon t1=0,t2=0;
for(lon i=2000;i<n1;i++)
t1+=nian(i);
for(lon i=2000;i<n2;i++)
t2+=nian(i);
t1+=yue(n1,y1);
t2+=yue(n2,y2);
t1+=(r1-1)*24*60*60+s1*60*60+f1*60+m1;
t2+=(r2-1)*24*60*60+s2*60*60+f2*60+m2;
ans=t2-t1;
}
}
int main()
{
freopen("two.in","r",stdin);
freopen("two.out","w",stdout);
scanf("%lld-%lld-%lld %lld:%lld:%lld",&n1,&y1,&r1,&s1,&f1,&m1);
scanf("%lld-%lld-%lld %lld:%lld:%lld",&n2,&y2,&r2,&s2,&f2,&m2);
work();
cout<<ans*1000;
fclose(stdin);
fclose(stdout);
return 0;
}