use std::io::{read_to_string, stdin};

fn main() {
    let temp = read_to_string(stdin()).unwrap();
    let mut iter = temp
        .split_ascii_whitespace()
        .map(|x| x.parse::<usize>().unwrap());
    let h = iter.next().unwrap();
    let m = iter.next().unwrap();

    println!("{}", 60 * h + m);
}
