#define _USE_MATH_DEFINES #include //cin, cout #include //vector #include //sort,min,max,count #include //string,getline, to_string #include //abs(int) #include //swap, pair #include //deque #include //INT_MAX #include //bitset #include //sqrt, ceil. M_PI, pow, sin #include //fixed #include //setprecision #include //stringstream #include //gcd, assumlate #include //randam_device #include //numeric_limits using namespace std; constexpr long long int D_MOD = 1000000007; inline vector SplitString(const string& str, const char key) { //文字列を任意の文字で分割 vector result; stringstream SS(str); string temp; while (std::getline(SS, temp, key)) { result.push_back(temp); } return(result); } inline vector CalcElapsedTime(int h1, int m1, int h2, int m2) { //h1時m1分~h2時m2分の経過時間を計算する vector ans(2); ans[1] = (m2 - m1 + 60) % 60; ans[0] = (h2 - h1 + 24 - (m2 < m1)) % 24; return ans; } int main() { int N; cin >> N; string temp; vector S1, S2; vector T(2); int ans = 0; for (int i = 0; i < N; i++) { cin >> temp; S1 = SplitString(temp, ':'); cin >> temp; S2 = SplitString(temp, ':'); T = CalcElapsedTime(stoi(S1[0]), stoi(S1[1]), stoi(S2[0]), stoi(S2[1])); ans = ans + T[0] * 60 + T[1]; } cout << ans << endl; return 0; }