#include #define ll long long #define ld long double #define rep(i,a,b) for (int i = a; i < b; i++) #define irep(i,a,b) for (int i = a; i > b; i--) #define print(n) cout << n << endl #define rup(a,b) (a+b-1)/b using namespace std; int calc(string a,string b){ int now = 0; int ha,sa; bool p = false; rep(i,0,a.size()){ if (a[i]==':'){ p = true; ha = now; now = 0; continue; } now *= 10; now += int(a[i]-'0'); } sa = now; int hb,sb; now = 0; rep(i,0,b.size()){ if(b[i]==':'){ hb = now; now = 0; continue; } now *= 10; now += int(b[i]-'0'); } sb = now; int count; count = hb - ha; if (count < 0) count += 24; count *= 60; count += sb - sa; return count; } int main(){ cout << fixed << setprecision(15); int n; cin >> n; int count = 0; rep(i,0,n){ string a,b; cin>>a>>b; count += calc(a,b); } print(count); //system("pause"); return 0; }