409235: GYM103464 B Palindromic Dates

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Palindromic Datestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Not so long ago Alexandis watched an interesting program on a well-known TV channel, in which it was said that important historical events occur on palindrome dates. Thus, for example, it was argued that... Wait a minute, what are palindromic dates?

As you know, any date can be represented as $$$DD$$$.$$$MM$$$.$$$Y^*$$$, where DD — is the day number, MM — is the month number, and $$$Y^*$$$ — is the current year number. So, for example, $$$5$$$ of April $$$1690$$$ can be represented as 05.04.1690, and, say, $$$29$$$ of December $$$192$$$ can be represented as 29.12.192. More formally, we can say that the day number is written using two digits, with perhaps zeros to the left if the number is less than ten. Similarly, the month number is written with two digits according to the same rules. The year number is written as a positive integer without leading zeros.

A palindrome is such a string that it reads equally from left to right and from right to left. For example, the string abacaba is a palindrome, but the string aaba is not.

But now how do we check if a date is a palindrome? It's pretty simple. We take the date as a string, remove the dots from the string, and then check to see if the string is a palindrome. So, for example, April 5th, $$$1690$$$ is not a palindrome date because the date representation 05.04.1690 with the dots removed looks like 05041690 and that string is not a palindrome. At the same time, say the twenty-ninth of December $$$192$$$ can be represented as 29.12.192, its representation without dots looks like 2912192, this string is a palindrome, and therefore the date is a palindrome.

In case you're still interested, the show on this TV channel claimed that it was on the palindrome date that people first saw Bigfoot, it was on the palindrome date that our planet was visited by aliens from Nibiru, and so on... There was quite a long list, which, frankly, was irrelevant to the task at hand.

Alexandis wondered: how many palindromic dates have there been since the very first day of our era, that is, since the first of January of the first year?

This problem uses the Gregorian calendar. In other words, a year is considered leap year if its number is divided by $$$4$$$. However, if the year number is divided by $$$100$$$ and not divided by $$$400$$$, then the year is not considered a leap year.

Input

The input is a single integer $$$n$$$ ($$$1 \le n \le 10^7$$$) — the number of days, counting from $$$1$$$ January $$$1$$$ year, among which Alexandis wants to find palindromic dates.

Output

Output a single non-negative integer — the number of palindromic dates among $$$n$$$ the first days of our era.

Scoring

In this problem there is a test score, i.e. for each test the points are given independently, and then summed up. Tests are conventionally divided into subtasks, and points are awarded for the completion of all tests of a subtask. The subtasks are given in the following table:

ConstraintsScore for the subtask
1$$$n \le 365$$$10
2$$$n \le 3650$$$15
3$$$n \le 3\cdot 10^5$$$50
4No additional constraints25

ExamplesInput
12
Output
1
Input
103
Output
3
Note

In the first test case, the only palindrome date is $$$11$$$ of January of the first year (11.01.1).

In the second test case, there are three palindromic dates: $$$11$$$ of January, $$$12$$$ of February, and $$$13$$$ of March (of the first year), i.e. 11.01.1, 12.02.1, and 13.03.1.

加入题单

上一题 下一题 算法标签: