#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__ f2(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, int *, int *);
int /*<<< orphan*/ stderr;
int main(int argc, char *noargs[]) {
  int m, n;
  int v, vmin, vmax;
  long long int res;
  scanf("%d %d", &n, &m);
  res = 0;
  if (3 * m >= n + 2) {
    vmax = (m < n - 1 ? m : n - 1);
    vmin = (1 > n - 2 * vmax ? 1 : n - 2 * vmax);
    fprintf(stderr, "vmin = %d vmax = %d\n", vmin, vmax);
    for (v = vmin; v <= vmax; ++v) {
      res += f2(n - v, m);
    }
  }
  printf("%lld\n", res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <scanf@plt>
movq   $0x0,-0x30(%rbp)
imul   $0x3,-0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jl     123e <main+0xfe>
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11a0 <main+0x60>
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    11a9 <main+0x69>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
sub    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jle    11d4 <main+0x94>
mov    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11e2 <main+0xa2>
mov    -0x18(%rbp),%eax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xe08(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     1239 <main+0xf9>
mov    -0x18(%rbp),%edi
sub    -0x1c(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1030 <f2@plt>
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1209 <main+0xc9>
jmp    123e <main+0xfe>
mov    -0x30(%rbp),%rsi
lea    0xdd2(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1060 <scanf@plt>
mov    0xc(%rsp),%ecx
lea    (%rcx,%rcx,2),%edx
mov    0x8(%rsp),%eax
lea    0x2(%rax),%esi
cmp    %esi,%edx
jl     11aa <main+0x6a>
lea    -0x1(%rax),%r14d
cmp    %r14d,%ecx
cmovl  %ecx,%r14d
sub    %r14d,%eax
sub    %r14d,%eax
test   %eax,%eax
mov    $0x1,%ebp
cmovg  %eax,%ebp
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1050 <fprintf@plt>
cmp    %r14d,%ebp
jle    11ae <main+0x6e>
xor    %ebx,%ebx
jmp    11da <main+0x9a>
not    %r14d
neg    %ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x8(%rsp),%edi
add    %ebp,%edi
mov    0xc(%rsp),%esi
call   1030 <f2@plt>
add    %rax,%rbx
add    $0xffffffff,%ebp
cmp    %ebp,%r14d
jne    11c0 <main+0x80>
lea    0xe3a(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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