#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 key(char);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main(void) {
  char string[32];
  int i, hand, count, temp;
  while (1) {
    scanf("%s\n", string);
    if (string[0] == '#')
      break;
    for (i = 0; i < strlen(string); i++) {
      temp = key(string[i]);
      if (i == 0) {
        hand = temp;
        count = 0;
      } else if ((hand == 0 && temp == 1) || (hand == 1 && temp == 0)) {
        count++;
        hand = temp;
      }
    }
    printf("%d\n", count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1060 <scanf@plt>
movsbl -0x30(%rbp),%eax
cmp    $0x23,%eax
jne    1171 <main+0x31>
jmp    1224 <main+0xe4>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x44(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
jge    1210 <main+0xd0>
movslq -0x34(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%edi
call   1030 <key@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    11c1 <main+0x81>
mov    -0x40(%rbp),%eax
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
jmp    11fd <main+0xbd>
cmpl   $0x0,-0x38(%rbp)
jne    11d5 <main+0x95>
cmpl   $0x1,-0x40(%rbp)
je     11e9 <main+0xa9>
cmpl   $0x1,-0x38(%rbp)
jne    11f8 <main+0xb8>
cmpl   $0x0,-0x40(%rbp)
jne    11f8 <main+0xb8>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    11fd <main+0xbd>
jmp    1202 <main+0xc2>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1178 <main+0x38>
mov    -0x3c(%rbp),%esi
lea    0xdea(%rip),%rdi
call   1050 <printf@plt>
jmp    114f <main+0xf>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xeab(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
cmpb   $0x23,(%rsp)
jne    1174 <main+0x34>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%r12
lea    0xe86(%rip),%r14
lea    0xe7b(%rip),%r15
jmp    11ac <main+0x6c>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r13d,%esi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
cmpb   $0x23,(%rsp)
je     1163 <main+0x23>
mov    %r12,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1190 <main+0x50>
movsbl (%rsp),%edi
call   1030 <key@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1040 <strlen@plt>
xor    %r13d,%r13d
cmp    $0x2,%eax
jl     1190 <main+0x50>
xor    %r13d,%r13d
mov    $0x1,%ebp
jmp    11f9 <main+0xb9>
nopl   (%rax)
add    $0x1,%r13d
mov    %eax,%ebx
add    $0x1,%rbp
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    1190 <main+0x50>
movsbl (%rsp,%rbp,1),%edi
call   1030 <key@plt>
test   %ebx,%ebx
jne    120b <main+0xcb>
cmp    $0x1,%eax
je     11e0 <main+0xa0>
cmp    $0x1,%ebx
jne    11e6 <main+0xa6>
test   %eax,%eax
je     11e0 <main+0xa0>
jmp    11e6 <main+0xa6>

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

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