#include #include using namespace std; int main() { int n; int total; cin >> n; for (int i = 0; i < n; i++) { string start; string end; cin >> start >> std::ws >> end; string tm; int stt; for (int j = 0; j < start.length(); j++) { if (start[j] == ':') { stt = 60 * stoi(tm); tm = ""; } else { tm += start[j]; } } stt += stoi(tm); tm = ""; int nd; for (int k = 0; k < end.length(); k++) { if (end[k] == ':') { nd = 60 * stoi(tm); tm = ""; } else { tm += end[k]; } } nd += stoi(tm); if (nd > stt) { total += nd - stt; } else { total += (60 * 24 - stt) + nd; } } cout << total << endl; return 0; }