#include<bits/stdc++.h>
using namespace std;
int sumx(char a[]){
    /*17:00
      17:32*/
    int i=(a[0]-48)*10*60+(a[1]-48)*60;
    int k=(a[3]-48)*10+(a[4]-48);
    int sum=i+k;
    return sum;
     
}
int main(){
    int m;
    cin>>m;
    char a[10],b[10];
    cin>>a;
    cin>>b;
    int y=sumx(b)-sumx(a);
    if(m%y==0){
        cout<<m/y;
    }else{
        cout<<m/y+1;
    }
    return 0;
}
/**************************************************************
	Problem: 1312
	User: lijinkai
	Language: C++
	Result: Accepted
	Time:8 ms
	Memory:2072 kb
****************************************************************/