시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 128 MB110352735.526%

문제

양의 정수의 각 자리의 변화가 증가와 감소를 번갈아가면서 나타날 때, 이 숫자를 "지그재그 수"라고 한다. 예를 들어, 2947은 자리가 2→9→4→7로 증가→감소→증가 순이기 때문에 지그재그 수이다. 또, 71946은 감소→증가→감소→증가이기 때문에 지그재그 수이다. 하지만, 123, 71446, 71442, 88은 지그재그 수가 아니다. 한 자리 정수는 지그재그 수이다.

A이상 B이하의 M의 배수 중 지그재그 수의 개수를 구하는 프로그램을 작성하시오.

입력

첫째 줄에 A, 둘째 줄에 B, 셋째 줄에 M이 주어진다. (1 ≤ A ≤ B ≤ 10500, 1 ≤ M ≤ 500)

출력

A이상 B이하의 M의 배수 중 지그재그 수의 개수를 10000으로 나눈 나머지를 출력한다.

예제 입력 1

100
200
5

예제 출력 1

13

105, 120, 130, 140, 150, 160, 165, 170, 175, 180, 185, 190, 195

예제 입력 2

6
1234567
3

예제 출력 2

246
W3sicHJvYmxlbV9pZCI6IjU1NDgiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM5YzBcdWFkZjhcdWM3YWNcdWFkZjggXHVjMjJiXHVjNzkwIiwiZGVzY3JpcHRpb24iOiI8cD5cdWM1OTFcdWM3NTggXHVjODE1XHVjMjE4XHVjNzU4IFx1YWMwMSBcdWM3OTBcdWI5YWNcdWM3NTggXHViY2MwXHVkNjU0XHVhYzAwIFx1Yzk5ZFx1YWMwMFx1YzY0MCBcdWFjMTBcdWMxOGNcdWI5N2MgXHViYzg4XHVhYzA4XHVjNTQ0XHVhYzAwXHViYTc0XHVjMTFjIFx1YjA5OFx1ZDBjMFx1YjBhMCBcdWI1NGMsIFx1Yzc3NCBcdWMyMmJcdWM3OTBcdWI5N2MgJnF1b3Q7XHVjOWMwXHVhZGY4XHVjN2FjXHVhZGY4IFx1YzIxOCZxdW90O1x1Yjc3Y1x1YWNlMCBcdWQ1NWNcdWIyZTQuIFx1YzYwOF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