#include <stdio.h>

int main()
{
    int h1, m1, h2, m2, k, hours = 0, minutes = 0, ans = 0;
    scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);

    hours = h2-h1;
    minutes = m2-m1;
    minutes += (hours*60);
    ans = minutes-k;

  printf("%d\n", ans);

}
