#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 */
int abs(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, int *, int *);
int main() {
  int i, j, k, n, rem, count = 0;
  scanf("%d %d %d", &i, &j, &k);
  for (int c = i; c <= j; c++) {
    n = c;
    int sum = 0;
    while (n > 0) {
      rem = n % 10;
      sum = sum * 10 + rem;
      n = n / 10;
    }
    if (abs(c - sum) % k == 0)
      count++;
  }
  printf("%d", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11e6 <main+0xb6>
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11b2 <main+0x82>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
imul   $0xa,-0x24(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
jmp    117d <main+0x4d>
mov    -0x20(%rbp),%edi
sub    -0x24(%rbp),%edi
call   1030 <abs@plt>
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    11d3 <main+0xa3>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d8 <main+0xa8>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1164 <main+0x34>
mov    -0x1c(%rbp),%esi
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1040 <scanf@plt>
mov    0xc(%rsp),%r10d
mov    0x8(%rsp),%r9d
xor    %esi,%esi
cmp    %r9d,%r10d
jle    1165 <main+0x45>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
xor    %esi,%esi
mov    0x4(%rsp),%r8d
mov    $0xcccccccd,%r11d
jmp    11a2 <main+0x82>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r10d,%ecx
sub    %edx,%ecx
mov    %ecx,%eax
neg    %eax
cmovs  %ecx,%eax
cltd
idiv   %r8d
cmp    $0x1,%edx
adc    $0x0,%esi
lea    0x1(%r10),%eax
cmp    %r9d,%r10d
mov    %eax,%r10d
je     1151 <main+0x31>
mov    $0x0,%edx
test   %r10d,%r10d
jle    1180 <main+0x60>
xor    %edx,%edx
mov    %r10d,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%rdx,%rdx,4),%edx
mov    %eax,%edi
imul   %r11,%rdi
shr    $0x23,%rdi
lea    (%rdi,%rdi,1),%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %eax,%ebx
sub    %ecx,%ebx
lea    (%rbx,%rdx,2),%edx
cmp    $0x9,%eax
mov    %edi,%eax
ja     11c0 <main+0xa0>
jmp    1180 <main+0x60>

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

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