package main import ( "fmt" "strconv" "strings" ) func main() { var N int fmt.Scan(&N) var ans int for i := 0; i < N; i++ { var s1, s2 string fmt.Scan(&s1, &s2) h1, _ := strconv.Atoi(strings.Split(s1, ":")[0]) m1, _ := strconv.Atoi(strings.Split(s1, ":")[1]) h2, _ := strconv.Atoi(strings.Split(s2, ":")[0]) m2, _ := strconv.Atoi(strings.Split(s2, ":")[1]) hm1 := h1*60 + m1 hm2 := h2*60 + m2 if hm1 > hm2 { hm2 += 60 * 24 } ans += hm2 - hm1 } fmt.Println(ans) }