1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define ff first
#define ss second


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int x,d,h,m; cin>>x>>d>>h>>m;
    int ans=0;
    int konce[6]={0,25,26,27,28,30};

    int poczatek=(d-23)*24*60+h*60+m;
    int koniec=(konce[x]-23)*24*60;

    if(poczatek<=6*24*60+2*60 && koniec>6*24*60+2*60) cout<<koniec-poczatek-60;
    else cout<<koniec-poczatek;
}