Karen and Morning

It is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a palindrome.

What is the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome?

Remember that a palindrome is a string that reads the same forwards and backwards. For instance, 05:39 is not a palindrome, because 05:39 backwards is 93:50. On the other hand, 05:50 is a palindrome, because 05:50 backwards is 05:50.

Input

The first and only line of input contains a single string in the format hh:mm (00 ≤  hh  ≤ 23, 00 ≤  mm  ≤ 59).

Output

Output a single integer on a line by itself, the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome.

Examples

Input

05:39

Output

11

Input

13:31

Output

0

Input

23:59

Output

1

Note

In the first test case, the minimum number of minutes Karen should sleep for is 11. She can wake up at 05:50, when the time is a palindrome.

In the second test case, Karen can wake up immediately, as the current time, 13:31, is already a palindrome.

In the third test case, the minimum number of minutes Karen should sleep for is 1 minute. She can wake up at 00:00, when the time is a palindrome.

 注意24:00换成00:00就可以

#include <iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	int hh,mm;
	scanf("%d:%d",&hh,&mm);
	int flag=1;int cnt=0;
	int hh1,hh2;
	int mm1,mm2;
	mm2=mm%10;
	mm1=mm/10;
	hh1=hh/10;
	hh2=hh%10;
//	cout<<hh1<<hh2<<mm1<<mm2;
	while(flag)
	{
	if((hh1==mm2)&&(hh2==mm1))
	{
	flag=0;	break;			
	}
	else {
		mm2++;cnt++;
		if(mm2==10){mm2=0;mm1++;
		if(mm1==6){hh2++,mm1=0;
			if((hh2==4)&&(hh1==2)){
			hh1==0,hh2=0,mm1=0,mm2=0;flag=0;
		}
		if(hh2==10){hh2=0;hh1++;
	}}}
	}	
	}
	cout<<cnt;
	return 0;
} 

猜你喜欢

转载自blog.csdn.net/weixin_41988545/article/details/81388958