#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
long abs(scalar_t__);
int /*<<< orphan*/ printf(char *, long);
scalar_t__ reverse(long);
int /*<<< orphan*/ scanf(char *, long *, long *, long *);
int main() {
  long i, j, k;
  long count = 0;
  scanf("%ld %ld %ld", &i, &j, &k);
  for (long l = i; l <= j; l++) {
    long diff = abs(l - reverse(l));
    if (diff % k == 0) {
      count++;
    }
  }
  printf("%ld", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xea2(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1060 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jg     11dc <main+0x9c>
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <reverse@plt>
mov    -0x40(%rbp),%rdi
sub    %rax,%rdi
call   1040 <abs@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cqto
idivq  -0x20(%rbp)
cmp    $0x0,%rdx
jne    11c6 <main+0x86>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11cb <main+0x8b>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1177 <main+0x37>
mov    -0x28(%rbp),%rsi
lea    0xe21(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xec2(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %rsp,%rdx
lea    0x8(%rsp),%rcx
call   1050 <scanf@plt>
mov    0x10(%rsp),%rbx
xor    %r14d,%r14d
cmp    (%rsp),%rbx
jle    119a <main+0x6a>
lea    0xea3(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
nopw   0x0(%rax,%rax,1)
cqto
idiv   %rcx
cmp    $0x1,%rdx
adc    $0x0,%r14
lea    0x1(%rbx),%rax
cmp    (%rsp),%rbx
mov    %rax,%rbx
jge    115e <main+0x2e>
mov    %rbx,%rdi
call   1030 <reverse@plt>
mov    %rbx,%rcx
sub    %rax,%rcx
mov    %rcx,%rax
neg    %rax
cmovs  %rcx,%rax
mov    0x8(%rsp),%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
jne    1180 <main+0x50>
xor    %edx,%edx
div    %ecx
jmp    1185 <main+0x55>

LLVM IR (-O0):
@.str = [12 x i8] c"%ld %ld %ld\00"
@.str.1 = [4 x i8] c"%ld\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %5
%8 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64* %2, i64* %3, i64* %4)
%9 = load i64, i64* %2
store i64 %9, i64* %6
br label %10
10: ; preds = %28, %0
%11 = load i64, i64* %6
%12 = load i64, i64* %3
%13 = icmp sle i64 %11, %12
br i1 %13, label %14, label %31
14: ; preds = %10
%15 = load i64, i64* %6
%16 = load i64, i64* %6
%17 = call i64 @reverse(i64 %16)
%18 = sub nsw i64 %15, %17
%19 = call i64 @abs(i64 %18)
store i64 %19, i64* %7
%20 = load i64, i64* %7
%21 = load i64, i64* %4
%22 = srem i64 %20, %21
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %14
%25 = load i64, i64* %5
%26 = add nsw i64 %25, 1
store i64 %26, i64* %5
br label %27
27: ; preds = %24, %14
br label %28
28: ; preds = %27
%29 = load i64, i64* %6
%30 = add nsw i64 %29, 1
store i64 %30, i64* %6
br label %10
31: ; preds = %10
%32 = load i64, i64* %5
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"%ld %ld %ld\00"
@.str.1 = [4 x i8] c"%ld\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = bitcast i64* %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = bitcast i64* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64* %1, i64* %2, i64* %3)
%8 = load i64, i64* %1
%9 = load i64, i64* %2
%10 = icmp sgt i64 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %14, %0
%12 = phi i64 [ 0, %0 ], [ %24, %14 ]
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %12)
ret i32 0
14: ; preds = %0, %14
%15 = phi i64 [ %24, %14 ], [ 0, %0 ]
%16 = phi i64 [ %25, %14 ], [ %8, %0 ]
%17 = call i64 @reverse(i64 %16)
%18 = sub nsw i64 %16, %17
%19 = call i64 @llvm.abs.i64(i64 %18, i1 true)
%20 = load i64, i64* %3
%21 = srem i64 %19, %20
%22 = icmp eq i64 %21, 0
%23 = zext i1 %22 to i64
%24 = add nuw nsw i64 %15, %23
%25 = add nsw i64 %16, 1
%26 = load i64, i64* %2
%27 = icmp slt i64 %16, %26
br i1 %27, label %14, label %11
}