#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,h,m,s;
char a,d;
cin>>h>>a>>m>>d>>s;
n+=h*3600+m*60+s;
cin>>h>>a>>m>>d>>s;
s+=h*3600+m*60;
cout<<n-s;
return 0;
}
/**************************************************************
Problem: 1101
User: zzz
Language: C++
Result: Accepted
Time:16 ms
Memory:2072 kb
****************************************************************/