#include<stdio.h>


int main(){

    int x , y, n,k, m,count=0,z;

    scanf("%d %d %d %d %d",&x,&y,&n,&m,&k);

    z=n-x;

    count=z*60;

    count+=m-y;

    count-=k;

    printf("%d",count);

    return 0;
}