#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;
int /*<<< orphan*/ printf(char *, long long);
scalar_t__ scanf(char *, int *);
int main() {
  int n, m, i, u;
  long long int ar[999];
  while (scanf("%d", &n) != EOF) {
    ar[1] = 1;
    ar[2] = 2;
    ar[3] = 3;
    for (i = 4; i <= n; i++) {
      ar[i] = ar[i - 1] + ar[i - 3] + 1;
    }
    printf("%lld\n", ar[n]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2e9f(%rip),%rcx
cmp    (%rcx),%rax
je     11e1 <main+0xc1>
movq   $0x1,-0x1f48(%rbp)
movq   $0x2,-0x1f40(%rbp)
movq   $0x3,-0x1f38(%rbp)
movl   $0x4,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11c4 <main+0xa4>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x1f50(%rbp,%rax,8),%rcx
ff
mov    -0x10(%rbp),%eax
sub    $0x3,%eax
cltq
add    -0x1f50(%rbp,%rax,8),%rcx
ff
add    $0x1,%rcx
movslq -0x10(%rbp),%rax
mov    %rcx,-0x1f50(%rbp,%rax,8)
ff
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117a <main+0x5a>
movslq -0x8(%rbp),%rax
mov    -0x1f50(%rbp,%rax,8),%rsi
ff
lea    0xe2c(%rip),%rdi
call   1030 <printf@plt>
jmp    1132 <main+0x12>
xor    %eax,%eax
add    $0x1f50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1f50,%rsp
lea    0xed9(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x2ea0(%rip),%r13
cmp    0x0(%r13),%rax
jne    1161 <main+0x41>
xor    %eax,%eax
add    $0x1f50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xeab(%rip),%r14
lea    0xea1(%rip),%r15
lea    0xc(%rsp),%r12
jmp    11a1 <main+0x81>
cs nopw 0x0(%rax,%rax,1)
movslq %r9d,%rax
mov    0x10(%rsp,%rax,8),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
cmp    0x0(%r13),%rax
je     114e <main+0x2e>
movaps 0xe58(%rip),%xmm0
movups %xmm0,0x18(%rsp)
movq   $0x3,0x28(%rsp)
mov    0xc(%rsp),%r9d
cmp    $0x4,%r9d
jl     1180 <main+0x60>
lea    0x1(%r9),%r8
cmp    $0x5,%r8d
jne    11e0 <main+0xc0>
mov    $0x4,%edx
mov    $0x3,%esi
jmp    1238 <main+0x118>
nopw   0x0(%rax,%rax,1)
lea    -0x4(%r8),%rdi
and    $0xfffffffffffffffe,%rdi
neg    %rdi
mov    $0x4,%edx
mov    $0x3,%esi
cs nopw 0x0(%rax,%rax,1)
nop
mov    -0x8(%rsp,%rdx,8),%rbx
mov    (%rsp,%rdx,8),%rcx
lea    (%rsi,%rbx,1),%rax
add    %rbx,%rsi
add    $0x1,%rsi
mov    %rsi,0x10(%rsp,%rdx,8)
lea    (%rcx,%rax,1),%rsi
add    $0x2,%rsi
mov    %rsi,0x18(%rsp,%rdx,8)
lea    (%rdi,%rdx,1),%rax
add    $0x2,%rax
add    $0x2,%rdx
cmp    $0x4,%rax
jne    1200 <main+0xe0>
test   $0x1,%r8b
je     1180 <main+0x60>
mov    -0x8(%rsp,%rdx,8),%rax
add    %rsi,%rax
add    $0x1,%rax
mov    %rax,0x10(%rsp,%rdx,8)
jmp    1180 <main+0x60>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [999 x i64]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [999 x i64]* %2 to i8*
%5 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i64, i64* @EOF
%7 = icmp eq i64 %5, %6
br i1 %7, label %62, label %8
8: ; preds = %0
%9 = getelementptr inbounds [999 x i64], [999 x i64]* %2, i64 0, i64 1
%10 = getelementptr inbounds [999 x i64], [999 x i64]* %2, i64 0, i64 3
%11 = bitcast i64* %9 to <2 x i64>*
br label %12
12: ; preds = %8, %54
store <2 x i64> <i64 1, i64 2>, <2 x i64>* %11
store i64 3, i64* %10
%13 = load i32, i32* %1
%14 = icmp slt i32 %13, 4
br i1 %14, label %54, label %15
15: ; preds = %12
%16 = add nuw i32 %13, 1
%17 = zext i32 %16 to i64
%18 = and i64 %17, 1
%19 = icmp eq i32 %16, 5
br i1 %19, label %43, label %20
20: ; preds = %15
%21 = add nsw i64 %17, -4
%22 = and i64 %21, -2
br label %23
23: ; preds = %23, %20
%24 = phi i64 [ 3, %20 ], [ %38, %23 ]
%25 = phi i64 [ 4, %20 ], [ %40, %23 ]
%26 = phi i64 [ 0, %20 ], [ %41, %23 ]
%27 = add nsw i64 %25, -3
%28 = getelementptr inbounds [999 x i64], [999 x i64]* %2, i64 0, i64 %27
%29 = load i64, i64* %28
%30 = add i64 %24, 1
%31 = add i64 %30, %29
%32 = getelementptr inbounds [999 x i64], [999 x i64]* %2, i64 0, i64 %25
store i64 %31, i64* %32
%33 = or i64 %25, 1
%34 = add nsw i64 %25, -2
%35 = getelementptr inbounds [999 x i64], [999 x i64]* %2, i64 0, i64 %34
%36 = load i64, i64* %35
%37 = add i64 %31, 1
%38 = add i64 %37, %36
%39 = getelementptr inbounds [999 x i64], [999 x i64]* %2, i64 0, i64 %33
store i64 %38, i64* %39
%40 = add nuw nsw i64 %25, 2
%41 = add i64 %26, 2
%42 = icmp eq i64 %41, %22
br i1 %42, label %43, label %23
43: ; preds = %23, %15
%44 = phi i64 [ 3, %15 ], [ %38, %23 ]
%45 = phi i64 [ 4, %15 ], [ %40, %23 ]
%46 = icmp eq i64 %18, 0
br i1 %46, label %54, label %47
47: ; preds = %43
%48 = add nsw i64 %45, -3
%49 = getelementptr inbounds [999 x i64], [999 x i64]* %2, i64 0, i64 %48
%50 = load i64, i64* %49
%51 = add i64 %44, 1
%52 = add i64 %51, %50
%53 = getelementptr inbounds [999 x i64], [999 x i64]* %2, i64 0, i64 %45
store i64 %52, i64* %53
br label %54
54: ; preds = %47, %43, %12
%55 = sext i32 %13 to i64
%56 = getelementptr inbounds [999 x i64], [999 x i64]* %2, i64 0, i64 %55
%57 = load i64, i64* %56
%58 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %57)
%59 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%60 = load i64, i64* @EOF
%61 = icmp eq i64 %59, %60
br i1 %61, label %62, label %12
62: ; preds = %54, %0
ret i32 0
}