#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 *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int array[60];
  int fake[60] = {0};
  int num = -1;
  int track = 0;
  int count = 0;
  int flag = 1;
  int powers = 0;
  int cal = 0;
  int i = 0;
  for (i = 0; i < 60; i++) {
    array[i] = -1;
  }
  while (num != 0) {
    scanf("%d", &num);
    if (num == 0)
      break;
    array[num - 1] = 1;
    ++powers;
  }
  while (flag != 0) {
    track = 0;
    cal = 0;
    num = -1;
    for (i = 0; i < 60; i++) {
      fake[i] = array[i];
    }
    while (num != 0) {
      scanf("%d", &num);
      if (track == 0 && num == 0) {
        flag = 0;
        break;
      }
      if (num == 0)
        break;
      ++track;
      if (fake[num - 1] == 1) {
        ++cal;
        fake[num - 1] = 0;
      } else if (fake[num - 1] == -1) {
        cal = 0;
      }
    }
    if (cal == powers)
      ++count;
  }
  printf("%d", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1f0(%rbp),%rdi
xor    %esi,%esi
mov    $0xf0,%edx
call   1040 <memset@plt>
movl   $0xffffffff,-0x1f4(%rbp)
ff ff ff
movl   $0x0,-0x1f8(%rbp)
movl   $0x0,-0x1fc(%rbp)
movl   $0x1,-0x200(%rbp)
movl   $0x0,-0x204(%rbp)
movl   $0x0,-0x208(%rbp)
movl   $0x0,-0x20c(%rbp)
movl   $0x0,-0x20c(%rbp)
cmpl   $0x3c,-0x20c(%rbp)
jge    11d8 <main+0xa8>
movslq -0x20c(%rbp),%rax
movl   $0xffffffff,-0x100(%rbp,%rax,4)
ff ff ff ff
mov    -0x20c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20c(%rbp)
jmp    11a5 <main+0x75>
jmp    11dd <main+0xad>
cmpl   $0x0,-0x1f4(%rbp)
je     1239 <main+0x109>
lea    0xe0f(%rip),%rdi
lea    -0x1f4(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x1f4(%rbp)
jne    120f <main+0xdf>
jmp    1239 <main+0x109>
mov    -0x1f4(%rbp),%eax
sub    $0x1,%eax
cltq
movl   $0x1,-0x100(%rbp,%rax,4)
mov    -0x204(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x204(%rbp)
jmp    11dd <main+0xad>
jmp    123e <main+0x10e>
cmpl   $0x0,-0x200(%rbp)
je     13b5 <main+0x285>
movl   $0x0,-0x1f8(%rbp)
movl   $0x0,-0x208(%rbp)
movl   $0xffffffff,-0x1f4(%rbp)
ff ff ff
movl   $0x0,-0x20c(%rbp)
cmpl   $0x3c,-0x20c(%rbp)
jge    12b0 <main+0x180>
movslq -0x20c(%rbp),%rax
mov    -0x100(%rbp,%rax,4),%ecx
movslq -0x20c(%rbp),%rax
mov    %ecx,-0x1f0(%rbp,%rax,4)
mov    -0x20c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20c(%rbp)
jmp    1273 <main+0x143>
jmp    12b5 <main+0x185>
cmpl   $0x0,-0x1f4(%rbp)
je     138f <main+0x25f>
lea    0xd37(%rip),%rdi
lea    -0x1f4(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x1f8(%rbp)
jne    12fe <main+0x1ce>
cmpl   $0x0,-0x1f4(%rbp)
jne    12fe <main+0x1ce>
movl   $0x0,-0x200(%rbp)
jmp    138f <main+0x25f>
cmpl   $0x0,-0x1f4(%rbp)
jne    1310 <main+0x1e0>
jmp    138f <main+0x25f>
mov    -0x1f8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1f8(%rbp)
mov    -0x1f4(%rbp),%eax
sub    $0x1,%eax
cltq
cmpl   $0x1,-0x1f0(%rbp,%rax,4)
01
jne    1362 <main+0x232>
mov    -0x208(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x208(%rbp)
mov    -0x1f4(%rbp),%eax
sub    $0x1,%eax
cltq
movl   $0x0,-0x1f0(%rbp,%rax,4)
jmp    138a <main+0x25a>
mov    -0x1f4(%rbp),%eax
sub    $0x1,%eax
cltq
cmpl   $0xffffffff,-0x1f0(%rbp,%rax,4)
ff
jne    1385 <main+0x255>
movl   $0x0,-0x208(%rbp)
jmp    138a <main+0x25a>
jmp    12b5 <main+0x185>
mov    -0x208(%rbp),%eax
cmp    -0x204(%rbp),%eax
jne    13b0 <main+0x280>
mov    -0x1fc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1fc(%rbp)
jmp    123e <main+0x10e>
mov    -0x1fc(%rbp),%esi
lea    0xc3e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1f8,%rsp
movl   $0xffffffff,0xc(%rsp)
ff
pcmpeqd %xmm0,%xmm0
movdqa %xmm0,0x10(%rsp)
movdqa %xmm0,0x20(%rsp)
movdqa %xmm0,0x30(%rsp)
movdqa %xmm0,0x40(%rsp)
movdqa %xmm0,0x50(%rsp)
movdqa %xmm0,0x60(%rsp)
movdqa %xmm0,0x70(%rsp)
movdqa %xmm0,0x80(%rsp)
movdqa %xmm0,0x90(%rsp)
movdqa %xmm0,0xa0(%rsp)
movdqa %xmm0,0xb0(%rsp)
movdqa %xmm0,0xc0(%rsp)
movdqa %xmm0,0xd0(%rsp)
movdqa %xmm0,0xe0(%rsp)
movdqa %xmm0,0xf0(%rsp)
lea    0xe3a(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
xor    %r12d,%r12d
mov    $0x0,%r13d
test   %eax,%eax
je     1211 <main+0xe1>
xor    %r13d,%r13d
lea    0xe15(%rip),%rbx
lea    0xc(%rsp),%rbp
cltq
movl   $0x1,0xc(%rsp,%rax,4)
add    $0x1,%r13d
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    11f0 <main+0xc0>
lea    0x10(%rsp),%r15
lea    0xde3(%rip),%rbx
lea    0xc(%rsp),%rbp
jmp    1245 <main+0x115>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %r13d,%r14d
sete   %cl
add    %ecx,%r12d
test   %al,%al
jne    12c8 <main+0x198>
movl   $0xffffffff,0xc(%rsp)
ff
mov    $0xf0,%edx
lea    0x100(%rsp),%rdi
mov    %r15,%rsi
call   1040 <memcpy@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
sete   %al
je     12c0 <main+0x190>
xor    %r14d,%r14d
jmp    1296 <main+0x166>
nopl   (%rax)
xor    %r14d,%r14d
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
je     1230 <main+0x100>
movslq %ecx,%rax
mov    0xfc(%rsp,%rax,4),%ecx
cmp    $0xffffffff,%ecx
je     1280 <main+0x150>
cmp    $0x1,%ecx
jne    1283 <main+0x153>
add    $0xffffffffffffffff,%rax
add    $0x1,%r14d
movl   $0x0,0x100(%rsp,%rax,4)
jmp    1283 <main+0x153>
nop
xor    %r14d,%r14d
jmp    1232 <main+0x102>
lea    0xd31(%rip),%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [60 x i32]
%3 = alloca [60 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = bitcast [60 x i32]* %3 to i8*
store i32 -1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 1, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %10
br label %12
12: ; preds = %19, %0
%13 = load i32, i32* %10
%14 = icmp slt i32 %13, 60
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %10
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [60 x i32], [60 x i32]* %2, i64 0, i64 %17
store i32 -1, i32* %18
br label %19
19: ; preds = %15
%20 = load i32, i32* %10
%21 = add nsw i32 %20, 1
store i32 %21, i32* %10
br label %12
22: ; preds = %12
br label %23
23: ; preds = %31, %22
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %38
26: ; preds = %23
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
br label %38
31: ; preds = %26
%32 = load i32, i32* %4
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [60 x i32], [60 x i32]* %2, i64 0, i64 %34
store i32 1, i32* %35
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %23
38: ; preds = %30, %23
br label %39
39: ; preds = %106, %38
%40 = load i32, i32* %7
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %107
42: ; preds = %39
store i32 0, i32* %5
store i32 0, i32* %9
store i32 -1, i32* %4
store i32 0, i32* %10
br label %43
43: ; preds = %54, %42
%44 = load i32, i32* %10
%45 = icmp slt i32 %44, 60
br i1 %45, label %46, label %57
46: ; preds = %43
%47 = load i32, i32* %10
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [60 x i32], [60 x i32]* %2, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = load i32, i32* %10
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [60 x i32], [60 x i32]* %3, i64 0, i64 %52
store i32 %50, i32* %53
br label %54
54: ; preds = %46
%55 = load i32, i32* %10
%56 = add nsw i32 %55, 1
store i32 %56, i32* %10
br label %43
57: ; preds = %43
br label %58
58: ; preds = %98, %57
%59 = load i32, i32* %4
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %99
61: ; preds = %58
%62 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%63 = load i32, i32* %5
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %69
65: ; preds = %61
%66 = load i32, i32* %4
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %69
68: ; preds = %65
store i32 0, i32* %7
br label %99
69: ; preds = %65, %61
%70 = load i32, i32* %4
%71 = icmp eq i32 %70, 0
br i1 %71, label %72, label %73
72: ; preds = %69
br label %99
73: ; preds = %69
%74 = load i32, i32* %5
%75 = add nsw i32 %74, 1
store i32 %75, i32* %5
%76 = load i32, i32* %4
%77 = sub nsw i32 %76, 1
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [60 x i32], [60 x i32]* %3, i64 0, i64 %78
%80 = load i32, i32* %79
%81 = icmp eq i32 %80, 1
br i1 %81, label %82, label %89
82: ; preds = %73
%83 = load i32, i32* %9
%84 = add nsw i32 %83, 1
store i32 %84, i32* %9
%85 = load i32, i32* %4
%86 = sub nsw i32 %85, 1
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [60 x i32], [60 x i32]* %3, i64 0, i64 %87
store i32 0, i32* %88
br label %98
89: ; preds = %73
%90 = load i32, i32* %4
%91 = sub nsw i32 %90, 1
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [60 x i32], [60 x i32]* %3, i64 0, i64 %92
%94 = load i32, i32* %93
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %97
96: ; preds = %89
store i32 0, i32* %9
br label %97
97: ; preds = %96, %89
br label %98
98: ; preds = %97, %82
br label %58
99: ; preds = %72, %68, %58
%100 = load i32, i32* %9
%101 = load i32, i32* %8
%102 = icmp eq i32 %100, %101
br i1 %102, label %103, label %106
103: ; preds = %99
%104 = load i32, i32* %6
%105 = add nsw i32 %104, 1
store i32 %105, i32* %6
br label %106
106: ; preds = %103, %99
br label %39
107: ; preds = %39
%108 = load i32, i32* %6
%109 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %108)
ret i32 0
}

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