1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <bits/stdc++.h>
using namespace std;

using ll = int64_t;

void solve() {
  int x, d, m, h;
  cin >> x >> d >> h >> m;

  
  map<int, int> end;
  end[1] = 25;
  end[2] = 26;
  end[3] = 27;
  end[4] = 28;
  end[5] = 30;

  int ans = (end[x] - d) * 24 * 60 - h * 60 - m;

  if(x == 5 && make_tuple(d, h, m) <= make_tuple(29, 2, 0)) {
    ans -= 60;
  }

  cout << ans;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}