#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 a = 0, b = 0, d = 0;
  int i, j, loop;
  char c[100];
  scanf("%d%c", &loop, &c);
  for (i = 0; i < loop; i++) {
    scanf(" %[^\n]", &c);
    for (j = 0; j < strlen(c); j++) {
      if (c[j] == '<') {
        a++;
      } else if (c[j] == '>' && a > 0) {
        a--;
        b++;
      } else {
      }
    }
    printf("%d\n", b);
    b = 0;
    a = 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xea2(%rip),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x80(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1256 <main+0x126>
lea    0xe7e(%rip),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x84(%rbp)
lea    -0x80(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x84(%rbp),%eax
cmp    %ecx,%eax
jge    122b <main+0xfb>
movslq -0x18(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x3c,%eax
jne    11db <main+0xab>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1218 <main+0xe8>
movslq -0x18(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x3e,%eax
jne    120e <main+0xde>
cmpl   $0x0,-0x8(%rbp)
jle    120e <main+0xde>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1213 <main+0xe3>
jmp    1213 <main+0xe3>
jmp    1218 <main+0xe8>
jmp    121d <main+0xed>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1199 <main+0x69>
mov    -0xc(%rbp),%esi
lea    0xdd7(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1174 <main+0x44>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xebb(%rip),%rdi
xor    %r12d,%r12d
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11f2 <main+0xc2>
lea    0x10(%rsp),%r13
lea    0xe9c(%rip),%r15
jmp    1195 <main+0x65>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
add    $0x1,%r12d
cmp    0xc(%rsp),%r12d
jge    11f2 <main+0xc2>
xor    %ebp,%ebp
lea    0xe67(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r13,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1180 <main+0x50>
xor    %ebx,%ebx
xor    %r14d,%r14d
xor    %ebp,%ebp
jmp    11d7 <main+0xa7>
nopl   (%rax)
add    $0x1,%r14d
add    $0x1,%rbx
mov    %r13,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1180 <main+0x50>
movzbl 0x10(%rsp,%rbx,1),%eax
cmp    $0x3c,%al
je     11c0 <main+0x90>
cmp    $0x3e,%al
jne    11c4 <main+0x94>
test   %r14d,%r14d
jle    11c4 <main+0x94>
add    $0xffffffff,%r14d
add    $0x1,%ebp
jmp    11c4 <main+0x94>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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