#include<iostream>
#include<string>
#include<fstream>
using namespace std;
int time_to_int(string time){
int time_int = 0;
int hour = 0;
int minute = 0;
if(time[0] != '0'){
hour = (int)(time[0] - 48);
time_int += hour * 60 * 10;
}
if(time[1] != '0'){
hour = (int)(time[1] - 48);
time_int += hour * 60;
}
if(time[3] != '0'){
minute = (int)(time[3] - 48);
time_int += minute * 10;
}
if(time[4] != '0'){
minute = (int)(time[4] - 48);
time_int += minute;
}
return time_int;
}
int gcd(int a, int b){
if(a<0)
return gcd(-a, b);
if(b<0)
return gcd(a, -b);
return (b == 0)? a : gcd(b, a % b);
}
int main(){
string s1, s2;
int fenzi;
int fenmu;
int m, time1, time2, time_dis;
//ifstream ifs("shuju.txt");