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