#include <bits/stdc++.h>
const double PI = acos(-1), EPS = 1e-7;
const int OO = 0x3f3f3f3f, N = 1e7 + 5, MOD = 1e9 + 7;
using namespace std;
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  fast();
  long long a, b, ta, tb, hh, mm;
  char c;
  cin >> a >> ta >> b >> tb >> hh >> c >> mm;
  long long A = hh * 60 + mm;
  long long B = A + ta;
  long long AA = 5 * 60;
  long long BB = AA + tb;
  long long ans = 0;
  while (AA < 24 * 60) {
    int x = max(A, AA);
    int y = min(B, BB);
    if (x < y) ans++;
    AA += b;
    BB = AA + tb;
  }
  cout << ans << '\n';
  ;
  return 0;
}
