#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__ EOF;
long gcd(long, long);
int /*<<< orphan*/ printf(char *, long);
scalar_t__ scanf(char *, long *, long *, long *);
int main(void) {
  long n, a, b, d, tota, totb, totab;
  while (scanf("%ld %ld %ld", &n, &a, &b) != EOF) {
    if (!(n | a | b))
      break;
    d = gcd(a, b);
    tota = n / a;
    totb = n / b;
    totab = n / ((a * b) / d);
    printf("%ld\n", tota + totb - totab);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1040 <scanf@plt>
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%rax
je     11f3 <main+0xc3>
mov    -0x10(%rbp),%rax
or     -0x18(%rbp),%rax
or     -0x20(%rbp),%rax
cmp    $0x0,%rax
jne    1182 <main+0x52>
jmp    11f3 <main+0xc3>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <gcd@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
cqto
idivq  -0x20(%rbp)
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
imul   -0x20(%rbp),%rax
cqto
idivq  -0x28(%rbp)
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rsi
add    -0x38(%rbp),%rsi
sub    -0x40(%rbp),%rsi
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0xf>
xor    %eax,%eax
add    $0x50,%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    0xebb(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
call   1040 <scanf@plt>
mov    0x2e8a(%rip),%r15
cmp    (%r15),%rax
jne    1174 <main+0x44>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%r12
lea    0x8(%rsp),%r13
mov    %rsp,%r14
jmp    11c2 <main+0x92>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ecx,%eax
xor    %edx,%edx
div    %edi
add    %r8,%rsi
sub    %rax,%rsi
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
lea    0xe51(%rip),%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %r14,%rcx
call   1040 <scanf@plt>
cmp    (%r15),%rax
je     1163 <main+0x33>
mov    0x8(%rsp),%rdi
mov    0x10(%rsp),%rax
or     %rdi,%rax
mov    (%rsp),%rsi
or     %rsi,%rax
je     1163 <main+0x33>
call   1050 <gcd@plt>
mov    %rax,%rdi
mov    0x10(%rsp),%rcx
mov    0x8(%rsp),%rbx
mov    %rcx,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     1210 <main+0xe0>
mov    %rcx,%rax
cqto
idiv   %rbx
mov    %rax,%r8
jmp    1219 <main+0xe9>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ecx,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%r8d
mov    (%rsp),%rbp
mov    %rcx,%rax
or     %rbp,%rax
shr    $0x20,%rax
je     1240 <main+0x110>
mov    %rcx,%rax
cqto
idiv   %rbp
mov    %rax,%rsi
jmp    1248 <main+0x118>
cs nopw 0x0(%rax,%rax,1)
mov    %ecx,%eax
xor    %edx,%edx
div    %ebp
mov    %eax,%esi
imul   %rbx,%rbp
mov    %rdi,%rax
or     %rbp,%rax
shr    $0x20,%rax
je     1270 <main+0x140>
mov    %rbp,%rax
cqto
idiv   %rdi
mov    %rax,%rdi
jmp    1278 <main+0x148>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%eax
xor    %edx,%edx
div    %edi
mov    %eax,%edi
mov    %rcx,%rax
or     %rdi,%rax
shr    $0x20,%rax
je     1190 <main+0x60>
mov    %rcx,%rax
cqto
idiv   %rdi
jmp    1196 <main+0x66>

LLVM IR (-O0):
@.str = [12 x i8] c"%ld %ld %ld\00"
@EOF = global i64 0
@.str.1 = [5 x i8] c"%ld\0A\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
%8 = alloca i64
store i32 0, i32* %1
br label %9
9: ; preds = %21, %0
%10 = call i64 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64* %2, i64* %3, i64* %4)
%11 = load i64, i64* @EOF
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %44
13: ; preds = %9
%14 = load i64, i64* %2
%15 = load i64, i64* %3
%16 = or i64 %14, %15
%17 = load i64, i64* %4
%18 = or i64 %16, %17
%19 = icmp ne i64 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %13
br label %44
21: ; preds = %13
%22 = load i64, i64* %3
%23 = load i64, i64* %4
%24 = call i64 @gcd(i64 %22, i64 %23)
store i64 %24, i64* %5
%25 = load i64, i64* %2
%26 = load i64, i64* %3
%27 = sdiv i64 %25, %26
store i64 %27, i64* %6
%28 = load i64, i64* %2
%29 = load i64, i64* %4
%30 = sdiv i64 %28, %29
store i64 %30, i64* %7
%31 = load i64, i64* %2
%32 = load i64, i64* %3
%33 = load i64, i64* %4
%34 = mul nsw i64 %32, %33
%35 = load i64, i64* %5
%36 = sdiv i64 %34, %35
%37 = sdiv i64 %31, %36
store i64 %37, i64* %8
%38 = load i64, i64* %6
%39 = load i64, i64* %7
%40 = add nsw i64 %38, %39
%41 = load i64, i64* %8
%42 = sub nsw i64 %40, %41
%43 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %42)
br label %9
44: ; preds = %20, %9
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"%ld %ld %ld\00"
@EOF = global i64 0
@.str.1 = [5 x i8] c"%ld\0A\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 i64 @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* @EOF
%9 = icmp eq i64 %7, %8
br i1 %9, label %33, label %10
10: ; preds = %0, %17
%11 = load i64, i64* %1
%12 = load i64, i64* %2
%13 = or i64 %12, %11
%14 = load i64, i64* %3
%15 = or i64 %13, %14
%16 = icmp eq i64 %15, 0
br i1 %16, label %33, label %17
17: ; preds = %10
%18 = call i64 @gcd(i64 %12, i64 %14)
%19 = load i64, i64* %1
%20 = load i64, i64* %2
%21 = sdiv i64 %19, %20
%22 = load i64, i64* %3
%23 = sdiv i64 %19, %22
%24 = mul nsw i64 %22, %20
%25 = sdiv i64 %24, %18
%26 = sdiv i64 %19, %25
%27 = add nsw i64 %23, %21
%28 = sub i64 %27, %26
%29 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %28)
%30 = call i64 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64* %1, i64* %2, i64* %3)
%31 = load i64, i64* @EOF
%32 = icmp eq i64 %30, %31
br i1 %32, label %33, label %10
33: ; preds = %17, %10, %0
ret i32 0
}