#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 rocks;
  scanf("%d", &rocks);
  char letter[26] = {0};
  int count = 0;
  for (int r = 0; r < rocks; r++) {
    char s[100];
    scanf("%s", s);
    for (int i = 0; i < strlen(s); i++) {
      char c = s[i];
      if (letter[c - 'a'] == r) {
        letter[c - 'a']++;
        if (letter[c - 'a'] == rocks) {
          count++;
        }
      }
    }
  }
  printf("%d", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x1a,%edx
call   1050 <memset@plt>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    126e <main+0x12e>
lea    -0xa0(%rbp),%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x0,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
mov    %eax,-0xac(%rbp)
lea    -0xa0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xac(%rbp),%eax
cmp    %ecx,%eax
jge    125b <main+0x11b>
movslq -0xa4(%rbp),%rax
mov    -0xa0(%rbp,%rax,1),%al
mov    %al,-0xa5(%rbp)
movsbl -0xa5(%rbp),%eax
sub    $0x61,%eax
cltq
movsbl -0x30(%rbp,%rax,1),%eax
cmp    -0x38(%rbp),%eax
jne    1242 <main+0x102>
movsbl -0xa5(%rbp),%eax
sub    $0x61,%eax
cltq
mov    -0x30(%rbp,%rax,1),%cl
add    $0x1,%cl
mov    %cl,-0x30(%rbp,%rax,1)
movsbl -0xa5(%rbp),%eax
sub    $0x61,%eax
cltq
movsbl -0x30(%rbp,%rax,1),%eax
cmp    -0x8(%rbp),%eax
jne    123d <main+0xfd>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1242 <main+0x102>
jmp    1247 <main+0x107>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    11ad <main+0x6d>
jmp    1260 <main+0x120>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1182 <main+0x42>
mov    -0x34(%rbp),%esi
lea    0xd88(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
lea    0xeb8(%rip),%rdi
xor    %r13d,%r13d
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
xorps  %xmm0,%xmm0
movups %xmm0,0x1a(%rsp)
movaps %xmm0,0x10(%rsp)
cmpl   $0x0,0xc(%rsp)
jle    11fb <main+0xcb>
lea    0xe8d(%rip),%r14
lea    0x30(%rsp),%r15
lea    0x10(%rsp),%r12
xor    %ebp,%ebp
xor    %r13d,%r13d
jmp    1199 <main+0x69>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jge    11fb <main+0xcb>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1190 <main+0x60>
xor    %ebx,%ebx
jmp    11d3 <main+0xa3>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1190 <main+0x60>
movsbq 0x30(%rsp,%rbx,1),%rax
movsbl -0x61(%rax,%r12,1),%ecx
cmp    %ecx,%ebp
jne    11c0 <main+0x90>
add    $0x1,%cl
mov    %cl,-0x51(%rsp,%rax,1)
movsbl %cl,%eax
xor    %ecx,%ecx
cmp    %eax,0xc(%rsp)
sete   %cl
add    %ecx,%r13d
jmp    11c0 <main+0x90>
lea    0xdfe(%rip),%rdi
mov    %r13d,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x98,%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 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [26 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca [100 x i8]
%7 = alloca i32
%8 = alloca i8
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = bitcast [26 x i8]* %3 to i8*
store i32 0, i32* %4
store i32 0, i32* %5
br label %11
11: ; preds = %63, %0
%12 = load i32, i32* %5
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %66
15: ; preds = %11
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %16)
store i32 0, i32* %7
br label %18
18: ; preds = %59, %15
%19 = load i32, i32* %7
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %62
23: ; preds = %18
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %25
%27 = load i8, i8* %26
store i8 %27, i8* %8
%28 = load i8, i8* %8
%29 = sext i8 %28 to i32
%30 = sub nsw i32 %29, 97
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = load i32, i32* %5
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %58
37: ; preds = %23
%38 = load i8, i8* %8
%39 = sext i8 %38 to i32
%40 = sub nsw i32 %39, 97
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = add i8 %43, 1
store i8 %44, i8* %42
%45 = load i8, i8* %8
%46 = sext i8 %45 to i32
%47 = sub nsw i32 %46, 97
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = load i32, i32* %2
%53 = icmp eq i32 %51, %52
br i1 %53, label %54, label %57
54: ; preds = %37
%55 = load i32, i32* %4
%56 = add nsw i32 %55, 1
store i32 %56, i32* %4
br label %57
57: ; preds = %54, %37
br label %58
58: ; preds = %57, %23
br label %59
59: ; preds = %58
%60 = load i32, i32* %7
%61 = add nsw i32 %60, 1
store i32 %61, i32* %7
br label %18
62: ; preds = %18
br label %63
63: ; preds = %62
%64 = load i32, i32* %5
%65 = add nsw i32 %64, 1
store i32 %65, i32* %5
br label %11
66: ; preds = %11
%67 = load i32, i32* %4
%68 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %67)
ret i32 0
}

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