#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 /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int k, r;
  int answer = 0;
  int sum = 0;
  int counter = 1;
  scanf("%d %d", &k, &r);
  while (1) {
    if ((counter * k - r) % 10 == 0 || counter * k % 10 == 0)
      break;
    else
      counter++;
  }
  printf("%d\n", counter);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
lea    0xeb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x18(%rbp),%eax
imul   -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     118b <main+0x6b>
mov    -0x18(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1190 <main+0x70>
jmp    119e <main+0x7e>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1158 <main+0x38>
mov    -0x18(%rbp),%esi
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%r8d
xor    %esi,%esi
xor    %r9d,%r9d
sub    (%rsp),%r9d
mov    %r8d,%edx
cs nopw 0x0(%rax,%rax,1)
lea    (%r9,%rdx,1),%edi
imul   $0xcccccccd,%edi,%edi
add    $0x19999998,%edi
ror    %edi
add    $0x1,%esi
cmp    $0x19999999,%edi
jb     1192 <main+0x72>
movslq %edx,%rdi
imul   $0x66666667,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
add    %r8d,%edx
test   %edi,%edi
jne    1150 <main+0x30>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = load i32, i32* %2
br label %8
8: ; preds = %8, %0
%9 = phi i32 [ 1, %0 ], [ %17, %8 ]
%10 = mul nsw i32 %6, %9
%11 = sub nsw i32 %10, %7
%12 = srem i32 %11, 10
%13 = icmp eq i32 %12, 0
%14 = srem i32 %10, 10
%15 = icmp eq i32 %14, 0
%16 = select i1 %13, i1 true, i1 %15
%17 = add nuw nsw i32 %9, 1
br i1 %16, label %18, label %8
18: ; preds = %8
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %9)
ret i32 0
}