#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 *, int);
scalar_t__ scanf(char *, ...);
int main(void) {
  int N, M;
  char action[10];
  while (scanf("%i %i", &N, &M) != EOF) {
    scanf("%s", action);
    (action[0] == 'f' ? N++, N++, N-- : (N > 0 ? N-- : 1));
  }
  printf("%i\n", N);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    0x2e9c(%rip),%rcx
cmp    (%rcx),%rax
je     11c6 <main+0xa6>
lea    -0x16(%rbp),%rsi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x16(%rbp),%eax
cmp    $0x66,%eax
jne    1194 <main+0x74>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    11c1 <main+0xa1>
cmpl   $0x0,-0x8(%rbp)
jle    11b1 <main+0x91>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
mov    %eax,-0x1c(%rbp)
jmp    11be <main+0x9e>
mov    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11be <main+0x9e>
mov    -0x1c(%rbp),%eax
jmp    112f <main+0xf>
mov    -0x8(%rbp),%esi
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%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    0xecb(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x2e9b(%rip),%rbp
cmp    0x0(%rbp),%rax
jne    1174 <main+0x54>
mov    0x4(%rsp),%esi
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe8b(%rip),%r14
lea    0xe(%rsp),%r15
lea    0xe79(%rip),%r12
lea    0x4(%rsp),%r13
lea    0x8(%rsp),%rbx
jmp    11bd <main+0x9d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%eax
mov    %eax,0x4(%rsp)
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
cmp    0x0(%rbp),%rax
je     1153 <main+0x33>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpb   $0x66,0xe(%rsp)
mov    0x4(%rsp),%eax
je     11a0 <main+0x80>
test   %eax,%eax
jle    11a7 <main+0x87>
add    $0xffffffff,%eax
jmp    11a3 <main+0x83>

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

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