#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 *, long long);
int /*<<< orphan*/ scanf(char *, long long *, int *);
int main() {
  long long int r;
  int c;
  scanf("%lld %d", &r, &c);
  if (r % 2 == 1) {
    printf("%lld", (r - 1) * 5 + 2 * (c - 1));
  } else {
    printf("%lld", (r - 2) * 5 + 2 * (c - 1) + 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x1,%rdx
jne    1186 <main+0x66>
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
imul   $0x5,%rax,%rsi
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
shl    $0x1,%eax
cltq
add    %rax,%rsi
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
jmp    11b0 <main+0x90>
mov    -0x10(%rbp),%rax
sub    $0x2,%rax
imul   $0x5,%rax,%rsi
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
shl    $0x1,%eax
cltq
add    %rax,%rsi
add    $0x1,%rsi
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1040 <scanf@plt>
mov    0x10(%rsp),%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
add    %rcx,%rdx
and    $0xfffffffffffffffe,%rdx
lea    (%rcx,%rcx,4),%rax
sub    %rdx,%rcx
cmp    $0x1,%rcx
jne    1170 <main+0x50>
mov    0xc(%rsp),%ecx
add    %ecx,%ecx
add    $0xfffffffe,%ecx
movslq %ecx,%rcx
lea    (%rax,%rcx,1),%rsi
add    $0xfffffffffffffffb,%rsi
jmp    1184 <main+0x64>
mov    0xc(%rsp),%ecx
add    %ecx,%ecx
add    $0xfffffffe,%ecx
movslq %ecx,%rcx
lea    (%rax,%rcx,1),%rsi
add    $0xfffffffffffffff7,%rsi
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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

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