 # W.C. 3.1 Indecisive Ryan

Ryan is very indecisive. He is very fond of football and loves playing around with numbers, so he thought of using number manipulation as a way of making decisions.

On any given day Ryan would love to go play irrespective of the fact that its raining and that he has homework. He even stays up late at night watching matches. The only condition for him to play is that the day should be a magical day.

Take a number, reverse it, subtract the two and if the number thus obtained is evenly divisible by a specific number, the day is a magical day. For eg, take a number 13, its reverse is 31, their difference is 18 which if divided by 6 is perfectly divisible hence 13th is a magical day. He will look at a numbered range of days and will only play on a magical day.

Given a range of numbered days [m.....n] , and a number p , determine the number of days in the range that are magical. Magical numbers are defined as numbers where |m - reverse(m)| is evenly divisible by p . If a day's value is a magical number, it is a magical day. Print the sum of number of magical days in the range.

Input Format:
A single line of three space-separated integers describing the respective values of m , n, and p.

Sample input:
20 23 6
Output:
2

Explanation:
Only two days, 20 and 22, in this interval are magical. Thus, we print 2 as our answer.

Submit final ans as sum of answers of all below testcases.

Test cases:
Input: 13 45 3
Input: 1 123456 13
Input: 123 456789 189
Input: 1 2000000 23047885

### You must be logged in to submit a solution

View ranklist for this challenge  