import std;

void main() {
    int h1, m1, h2, m2, k; scan(h1, m1, h2, m2, k);

    int a = h1 * 60 + m1;
    int b = h2 * 60 + m2;
    writeln(max(0, b - a - k));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;
