1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use std::io;

fn konw(d: usize, h: usize, m: usize) -> usize {
    return d * (60 * 24) + h * 60 + m;
}

fn main() {
    let mut s: String =  String::new();
    io::stdin().read_line(&mut s).unwrap();
    let a: Vec<usize> = s.split_whitespace().
        map(|x| x.parse().unwrap()).
        collect();
    let x: usize = a[0];
    let d: usize = a[1];
    let h: usize = a[2];
    let m: usize = a[3];
    let konce: Vec<usize> = vec![24, 25, 26, 27, 29];
    let poc = konw(d, h, m);
    let mut kon: usize = konw(konce[x - 1], 23, 59);
    if x == 5 && (d <= 28 || h < 2) {
        kon = kon - 60;
    }
    println!("{}", kon - poc + 1);
}