#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 */
scalar_t__ calloc(int, int);
int cifra(int, int, int);
int dobi_dolzino(int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  int d_a = dobi_dolzino(a);
  int d_b = dobi_dolzino(b);
  int *st = (int *)calloc(10, sizeof(int));
  for (int i = 1; i < d_a + 1; ++i) {
    for (int j = 1; j < d_b + 1; ++j) {
      int c_a = cifra(a, i, d_a);
      int c_b = cifra(b, j, d_b);
      st[c_a] = 1;
      st[c_b] = 1;
    }
  }
  int c = 0;
  for (int i = 0; i < 10; ++i) {
    c += st[i];
  }
  printf("%d\n", c);
  free(st);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1080 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1070 <dobi_dolzino@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <dobi_dolzino@plt>
mov    %eax,-0x14(%rbp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    123d <main+0xdd>
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    122a <main+0xca>
mov    -0x8(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <cifra@plt>
mov    %eax,-0x2c(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <cifra@plt>
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11cb <main+0x6b>
jmp    122f <main+0xcf>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b3 <main+0x53>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    1274 <main+0x114>
mov    -0x20(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    124b <main+0xeb>
mov    -0x34(%rbp),%esi
lea    0xd88(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe8b(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1080 <scanf@plt>
mov    0x14(%rsp),%edi
call   1070 <dobi_dolzino@plt>
mov    %eax,%r15d
mov    0x10(%rsp),%edi
call   1070 <dobi_dolzino@plt>
mov    %eax,%ebp
mov    $0xa,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,%r13
test   %r15d,%r15d
jle    123c <main+0xdc>
mov    %ebp,%r14d
neg    %r14d
mov    $0x1,%r12d
mov    %ebp,0xc(%rsp)
jmp    11e1 <main+0x81>
nopl   0x0(%rax,%rax,1)
lea    0x1(%r12),%eax
cmp    %r15d,%r12d
mov    %eax,%r12d
mov    0xc(%rsp),%ebp
je     123c <main+0xdc>
test   %ebp,%ebp
jle    11d0 <main+0x70>
mov    $0x1,%ebp
nopw   0x0(%rax,%rax,1)
mov    0x14(%rsp),%edi
mov    %r12d,%esi
mov    %r15d,%edx
call   1040 <cifra@plt>
mov    %eax,%ebx
mov    0x10(%rsp),%edi
mov    %ebp,%esi
mov    0xc(%rsp),%edx
call   1040 <cifra@plt>
movslq %ebx,%rcx
movl   $0x1,0x0(%r13,%rcx,4)
cltq
movl   $0x1,0x0(%r13,%rax,4)
lea    (%r14,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    11f0 <main+0x90>
jmp    11d0 <main+0x70>
movdqu 0x8(%r13),%xmm0
movdqu 0x18(%r13),%xmm1
paddd  %xmm0,%xmm1
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%esi
add    0x4(%r13),%esi
add    0x0(%r13),%esi
lea    0xd95(%rip),%rdi
call   1050 <printf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
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*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %1
%13 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%14 = load i32, i32* %2
%15 = call i32 @dobi_dolzino(i32 %14)
store i32 %15, i32* %4
%16 = load i32, i32* %3
%17 = call i32 @dobi_dolzino(i32 %16)
store i32 %17, i32* %5
%18 = call i64 @calloc(i32 10, i32 4)
%19 = inttoptr i64 %18 to i32*
store i32* %19, i32** %6
store i32 1, i32* %7
br label %20
20: ; preds = %52, %0
%21 = load i32, i32* %7
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %55
25: ; preds = %20
store i32 1, i32* %8
br label %26
26: ; preds = %48, %25
%27 = load i32, i32* %8
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
%30 = icmp slt i32 %27, %29
br i1 %30, label %31, label %51
31: ; preds = %26
%32 = load i32, i32* %2
%33 = load i32, i32* %7
%34 = load i32, i32* %4
%35 = call i32 @cifra(i32 %32, i32 %33, i32 %34)
store i32 %35, i32* %9
%36 = load i32, i32* %3
%37 = load i32, i32* %8
%38 = load i32, i32* %5
%39 = call i32 @cifra(i32 %36, i32 %37, i32 %38)
store i32 %39, i32* %10
%40 = load i32*, i32** %6
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, i64 %42
store i32 1, i32* %43
%44 = load i32*, i32** %6
%45 = load i32, i32* %10
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %44, i64 %46
store i32 1, i32* %47
br label %48
48: ; preds = %31
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
br label %26
51: ; preds = %26
br label %52
52: ; preds = %51
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
br label %20
55: ; preds = %20
store i32 0, i32* %11
store i32 0, i32* %12
br label %56
56: ; preds = %67, %55
%57 = load i32, i32* %12
%58 = icmp slt i32 %57, 10
br i1 %58, label %59, label %70
59: ; preds = %56
%60 = load i32*, i32** %6
%61 = load i32, i32* %12
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %60, i64 %62
%64 = load i32, i32* %63
%65 = load i32, i32* %11
%66 = add nsw i32 %65, %64
store i32 %66, i32* %11
br label %67
67: ; preds = %59
%68 = load i32, i32* %12
%69 = add nsw i32 %68, 1
store i32 %69, i32* %12
br label %56
70: ; preds = %56
%71 = load i32, i32* %11
%72 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %71)
%73 = load i32*, i32** %6
%74 = call i32 @free(i32* %73)
ret i32 0
}

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 = call i32 @dobi_dolzino(i32 %6)
%8 = load i32, i32* %2
%9 = call i32 @dobi_dolzino(i32 %8)
%10 = call i64 @calloc(i32 10, i32 4)
%11 = inttoptr i64 %10 to i32*
%12 = icmp slt i32 %7, 1
br i1 %12, label %17, label %13
13: ; preds = %0
%14 = icmp slt i32 %9, 1
br label %15
15: ; preds = %13, %29
%16 = phi i32 [ 1, %13 ], [ %30, %29 ]
br i1 %14, label %29, label %32
17: ; preds = %29, %0
%18 = load i32, i32* %11
%19 = getelementptr inbounds i32, i32* %11, i64 1
%20 = load i32, i32* %19
%21 = getelementptr inbounds i32, i32* %11, i64 2
%22 = bitcast i32* %21 to <8 x i32>*
%23 = load <8 x i32>, <8 x i32>* %22
%24 = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %23)
%25 = add nsw i32 %24, %20
%26 = add nsw i32 %25, %18
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = call i32 @free(i32* %11)
ret i32 0
29: ; preds = %32, %15
%30 = add nuw i32 %16, 1
%31 = icmp eq i32 %16, %7
br i1 %31, label %17, label %15
32: ; preds = %15, %32
%33 = phi i32 [ %42, %32 ], [ 1, %15 ]
%34 = load i32, i32* %1
%35 = call i32 @cifra(i32 %34, i32 %16, i32 %7)
%36 = load i32, i32* %2
%37 = call i32 @cifra(i32 %36, i32 %33, i32 %9)
%38 = sext i32 %35 to i64
%39 = getelementptr inbounds i32, i32* %11, i64 %38
store i32 1, i32* %39
%40 = sext i32 %37 to i64
%41 = getelementptr inbounds i32, i32* %11, i64 %40
store i32 1, i32* %41
%42 = add nuw i32 %33, 1
%43 = icmp eq i32 %33, %9
br i1 %43, label %29, label %32
}