#include <iostream>
using namespace std;
int main() {
int H1, M1, H2, M2;
cin >> H1 >> M1;
cin >> H2 >> M2;
int inicio_en_minutos = H1 * 60 + M1;
int fin_en_minutos = H2 * 60 + M2;
int diferencia = fin_en_minutos - inicio_en_minutos;
cout << diferencia << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCmludCBtYWluKCkgewogICAgaW50IEgxLCBNMSwgSDIsIE0yOwogICAgY2luID4+IEgxID4+IE0xOwogICAgY2luID4+IEgyID4+IE0yOwogICAgaW50IGluaWNpb19lbl9taW51dG9zID0gSDEgKiA2MCArIE0xOwogICAgaW50IGZpbl9lbl9taW51dG9zID0gSDIgKiA2MCArIE0yOwogICAgaW50IGRpZmVyZW5jaWEgPSBmaW5fZW5fbWludXRvcyAtIGluaWNpb19lbl9taW51dG9zOwogICAgY291dCA8PCBkaWZlcmVuY2lhIDw8IGVuZGw7CiAKICAgIHJldHVybiAwOwp9