#include <bits/stdc++.h> using namespace std; int main(){int h1,m1,h2,m2;cin>>h1>>m1>>h2>>m2;cout<<(h260+m2-h160-m1)<<"\n";}