#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int strlen(char *);
int main() {
  int n;
  int i, j, k;
  int len;
  int cnt;
  char line[1024];
  scanf("%d\n", &n);
  for (i = 0; i < n; ++i) {
    gets(line);
    len = strlen(line);
    cnt = 0;
    j = 0;
    while (j < len) {
      if (line[j] > 0) {
        j++;
      } else if (line[j] < 0) {
        j += 2;
        cnt++;
      }
    }
    printf("%d\n", cnt);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121b <main+0xdb>
lea    -0x420(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x420(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11fe <main+0xbe>
movslq -0x10(%rbp),%rax
movsbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
jle    11cd <main+0x8d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11f9 <main+0xb9>
movslq -0x10(%rbp),%rax
movsbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
jge    11f4 <main+0xb4>
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f9 <main+0xb9>
jmp    119e <main+0x5e>
mov    -0x1c(%rbp),%esi
lea    0xdf8(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1169 <main+0x29>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x410,%rsp
lea    0xeae(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11cb <main+0x8b>
xor    %ebp,%ebp
lea    0x10(%rsp),%rbx
lea    0xe8f(%rip),%r14
jmp    1191 <main+0x51>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jge    11cb <main+0x8b>
mov    %rbx,%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    $0x0,%esi
test   %eax,%eax
jle    1180 <main+0x40>
xor    %esi,%esi
xor    %ecx,%ecx
jmp    11b7 <main+0x77>
add    $0x1,%ecx
cmp    %eax,%ecx
jge    1180 <main+0x40>
movslq %ecx,%rdx
cmpb   $0x0,0x10(%rsp,%rdx,1)
jg     11b0 <main+0x70>
jns    11b3 <main+0x73>
add    $0x2,%ecx
add    $0x1,%esi
jmp    11b3 <main+0x73>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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