#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 checkString(char *, int, int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int len;
  int i, j;
  scanf("%d", &len);
  char *s = (char *)malloc(512000 * sizeof(char));
  scanf("%s", s);
  int max = 0;
  int maxI, maxJ;
  for (i = 0; i < 26; i++) {
    int flag = 1;
    for (j = i + 1; j < 26; j++) {
      int ans = checkString(s, i, j, len);
      if (ans > max) {
        max = ans;
        maxI = i;
        maxJ = j;
      }
    }
  }
  if (max != 0) {
    printf("%d", max + 1);
  } else {
    printf("0");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    $0x7d000,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x1a,-0xc(%rbp)
jge    120c <main+0xcc>
movl   $0x1,-0x28(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1a,-0x10(%rbp)
jge    11f9 <main+0xb9>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%ecx
call   1040 <checkString@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    11e6 <main+0xa6>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11eb <main+0xab>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a9 <main+0x69>
jmp    11fe <main+0xbe>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118f <main+0x4f>
cmpl   $0x0,-0x1c(%rbp)
je     122f <main+0xef>
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123d <main+0xfd>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe9d(%rip),%rdi
xor    %r12d,%r12d
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    $0x7d000,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
lea    0xe7d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
xor    %ebx,%ebx
jmp    11a6 <main+0x56>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x1a,%r12d
je     11e0 <main+0x90>
mov    %r12d,%r15d
lea    0x1(%r15),%r12d
cmp    $0x18,%r15d
ja     11a0 <main+0x50>
mov    %r12d,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    0xc(%rsp),%ecx
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebp,%edx
call   1050 <checkString@plt>
cmp    %ebx,%eax
cmovg  %eax,%ebx
add    $0x1,%ebp
cmp    $0x1a,%ebp
jne    11c0 <main+0x70>
jmp    11a0 <main+0x50>
test   %ebx,%ebx
je     11f9 <main+0xa9>
add    $0x1,%ebx
lea    0xe12(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1203 <main+0xb3>
mov    $0x30,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
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"
@.str.2 = [2 x i8] c"0\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%12 = call i64 @malloc(i32 512000)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %5
%14 = load i8*, i8** %5
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %14)
store i32 0, i32* %6
store i32 0, i32* %3
br label %16
16: ; preds = %43, %0
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 26
br i1 %18, label %19, label %46
19: ; preds = %16
store i32 1, i32* %9
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %22
22: ; preds = %39, %19
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 26
br i1 %24, label %25, label %42
25: ; preds = %22
%26 = load i8*, i8** %5
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = load i32, i32* %2
%30 = call i32 @checkString(i8* %26, i32 %27, i32 %28, i32 %29)
store i32 %30, i32* %10
%31 = load i32, i32* %10
%32 = load i32, i32* %6
%33 = icmp sgt i32 %31, %32
br i1 %33, label %34, label %38
34: ; preds = %25
%35 = load i32, i32* %10
store i32 %35, i32* %6
%36 = load i32, i32* %3
store i32 %36, i32* %7
%37 = load i32, i32* %4
store i32 %37, i32* %8
br label %38
38: ; preds = %34, %25
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %22
42: ; preds = %22
br label %43
43: ; preds = %42
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
br label %16
46: ; preds = %16
%47 = load i32, i32* %6
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %46
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %51)
br label %55
53: ; preds = %46
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %55
55: ; preds = %53, %49
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 = bitcast i32* %1 to i8*
%3 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = call i64 @malloc(i32 512000)
%5 = inttoptr i64 %4 to i8*
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %10
7: ; preds = %15, %10
%8 = phi i32 [ %12, %10 ], [ %21, %15 ]
%9 = icmp eq i32 %13, 26
br i1 %9, label %24, label %10
10: ; preds = %0, %7
%11 = phi i32 [ 0, %0 ], [ %13, %7 ]
%12 = phi i32 [ 0, %0 ], [ %8, %7 ]
%13 = add nuw nsw i32 %11, 1
%14 = icmp ult i32 %11, 25
br i1 %14, label %15, label %7
15: ; preds = %10, %15
%16 = phi i32 [ %22, %15 ], [ %13, %10 ]
%17 = phi i32 [ %21, %15 ], [ %12, %10 ]
%18 = load i32, i32* %1
%19 = call i32 @checkString(i8* %5, i32 %11, i32 %16, i32 %18)
%20 = icmp sgt i32 %19, %17
%21 = select i1 %20, i32 %19, i32 %17
%22 = add nuw nsw i32 %16, 1
%23 = icmp eq i32 %22, 26
br i1 %23, label %7, label %15
24: ; preds = %7
%25 = icmp eq i32 %8, 0
br i1 %25, label %29, label %26
26: ; preds = %24
%27 = add nsw i32 %8, 1
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %27)
br label %31
29: ; preds = %24
%30 = call i32 @putchar(i32 48)
br label %31
31: ; preds = %29, %26
ret i32 0
}