#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 strlen(char *);
int main(int argc, char *argv[]) {
  int i;
  int t;
  int c[1 << 19];
  scanf("%d", &t);
  for (i = 0; i < t; i++) {
    char op[2];
    char x[255];
    scanf("%s %s", op, x);
    int n = 0;
    int j = 0;
    for (j = 0; j < strlen(x); j++) {
      if (x[j] % 2 == 1) {
        n = (n << 1) + 1;
      } else {
        n = (n << 1);
      }
    }
    if (*op == '+') {
      c[n]++;
    } else if (*op == '-') {
      c[n]--;
    } else {
      printf("%d\n", c[n]);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb0(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    12bb <main+0x18b>
lea    -0x200022(%rbp),%rsi
lea    -0x200130(%rbp),%rdx
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x200134(%rbp)
movl   $0x0,-0x200138(%rbp)
movl   $0x0,-0x200138(%rbp)
mov    -0x200138(%rbp),%eax
mov    %eax,-0x20013c(%rbp)
lea    -0x200130(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20013c(%rbp),%eax
cmp    %ecx,%eax
jge    122f <main+0xff>
movslq -0x200138(%rbp),%rax
movsbl -0x200130(%rbp,%rax,1),%eax
ff
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1207 <main+0xd7>
mov    -0x200134(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x200134(%rbp)
jmp    1216 <main+0xe6>
mov    -0x200134(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x200134(%rbp)
jmp    121b <main+0xeb>
mov    -0x200138(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x200138(%rbp)
jmp    11a8 <main+0x78>
movsbl -0x200022(%rbp),%eax
cmp    $0x2b,%eax
jne    125c <main+0x12c>
movslq -0x200134(%rbp),%rax
mov    -0x200020(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x200020(%rbp,%rax,4)
jmp    12a8 <main+0x178>
movsbl -0x200022(%rbp),%eax
cmp    $0x2d,%eax
jne    1289 <main+0x159>
movslq -0x200134(%rbp),%rax
mov    -0x200020(%rbp,%rax,4),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x200020(%rbp,%rax,4)
jmp    12a3 <main+0x173>
movslq -0x200134(%rbp),%rax
mov    -0x200020(%rbp,%rax,4),%esi
lea    0xd6b(%rip),%rdi
call   1040 <printf@plt>
jmp    12a8 <main+0x178>
jmp    12ad <main+0x17d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1162 <main+0x32>
mov    -0x4(%rbp),%eax
add    $0x200140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x200118,%rsp
lea    0xeb8(%rip),%rdi
xor    %r13d,%r13d
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    123d <main+0x10d>
lea    0xe9a(%rip),%r14
lea    0xa(%rsp),%r15
lea    0x10(%rsp),%rbx
jmp    11a2 <main+0x72>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x110(%rsp,%rax,4),%esi
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
add    $0x1,%r13d
cmp    0xc(%rsp),%r13d
jge    123d <main+0x10d>
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11ff <main+0xcf>
xor    %r12d,%r12d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x10(%rsp,%r12,1),%eax
mov    %eax,%ecx
shr    $0x7,%cl
add    %al,%cl
and    $0xfe,%cl
sub    %cl,%al
xor    %ecx,%ecx
cmp    $0x1,%al
sete   %cl
lea    (%rcx,%rbp,2),%ebp
add    $0x1,%r12
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%r12
jl     11d0 <main+0xa0>
mov    0xa(%rsp),%cl
movslq %ebp,%rax
cmp    $0x2d,%cl
je     1230 <main+0x100>
cmp    $0x2b,%cl
jne    1180 <main+0x50>
addl   $0x1,0x110(%rsp,%rax,4)
01
jmp    1193 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
addl   $0xffffffff,0x110(%rsp,%rax,4)
ff
jmp    1193 <main+0x63>
xor    %eax,%eax
add    $0x200118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%s %s\00"
@.str.2 = [4 x i8] c"%d\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 [524288 x i32]
%9 = alloca [2 x i8]
%10 = alloca [255 x i8]
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
store i32 0, i32* %6
br label %14
14: ; preds = %76, %2
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %79
18: ; preds = %14
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%20 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* %20)
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %12
br label %22
22: ; preds = %43, %18
%23 = load i32, i32* %12
%24 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
%26 = icmp slt i32 %23, %25
br i1 %26, label %27, label %46
27: ; preds = %22
%28 = load i32, i32* %12
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = srem i32 %32, 2
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %39
35: ; preds = %27
%36 = load i32, i32* %11
%37 = shl i32 %36, 1
%38 = add nsw i32 %37, 1
store i32 %38, i32* %11
br label %42
39: ; preds = %27
%40 = load i32, i32* %11
%41 = shl i32 %40, 1
store i32 %41, i32* %11
br label %42
42: ; preds = %39, %35
br label %43
43: ; preds = %42
%44 = load i32, i32* %12
%45 = add nsw i32 %44, 1
store i32 %45, i32* %12
br label %22
46: ; preds = %22
%47 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 43
br i1 %50, label %51, label %57
51: ; preds = %46
%52 = load i32, i32* %11
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [524288 x i32], [524288 x i32]* %8, i64 0, i64 %53
%55 = load i32, i32* %54
%56 = add nsw i32 %55, 1
store i32 %56, i32* %54
br label %75
57: ; preds = %46
%58 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 45
br i1 %61, label %62, label %68
62: ; preds = %57
%63 = load i32, i32* %11
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [524288 x i32], [524288 x i32]* %8, i64 0, i64 %64
%66 = load i32, i32* %65
%67 = add nsw i32 %66, -1
store i32 %67, i32* %65
br label %74
68: ; preds = %57
%69 = load i32, i32* %11
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [524288 x i32], [524288 x i32]* %8, i64 0, i64 %70
%72 = load i32, i32* %71
%73 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %72)
br label %74
74: ; preds = %68, %62
br label %75
75: ; preds = %74, %51
br label %76
76: ; preds = %75
%77 = load i32, i32* %6
%78 = add nsw i32 %77, 1
store i32 %78, i32* %6
br label %14
79: ; preds = %14
%80 = load i32, i32* %3
ret i32 %80
}

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