#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 *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int strlen(char *);
int main() {
  int i, l, p, max = 0;
  int *h = malloc(sizeof(int) * 26);
  for (int h_i = 0; h_i < 26; h_i++) {
    scanf("%d", &h[h_i]);
  }
  char *word = (char *)malloc(512000 * sizeof(char));
  scanf("%s", word);
  l = strlen(word);
  for (i = 0; i < l; i++) {
    p = word[i] - 'a';
    if (h[p] > max)
      max = h[p];
  }
  printf("%d", (max * l));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x68,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x1a,-0x24(%rbp)
jge    11a0 <main+0x60>
mov    -0x20(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116b <main+0x2b>
mov    $0x7d000,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1226 <main+0xe6>
mov    -0x30(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x61,%eax
mov    %eax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x14(%rbp),%eax
jle    1213 <main+0xd3>
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
jmp    1218 <main+0xd8>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d3 <main+0x93>
mov    -0x14(%rbp),%esi
imul   -0xc(%rbp),%esi
lea    0xdcc(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x68,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
lea    0xea5(%rip),%r14
xor    %ebx,%ebx
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x4(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x8(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xc(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x10(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x14(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x18(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x1c(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x20(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x24(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x28(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x2c(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x30(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x34(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x38(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x3c(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x40(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x44(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x48(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x4c(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x50(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x54(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x58(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x5c(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x60(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x64(%r15),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    $0x7d000,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
lea    0xd27(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    133b <main+0x1fb>
mov    %eax,%esi
lea    -0x1(%rsi),%rdx
mov    %esi,%ecx
and    $0x3,%ecx
cmp    $0x3,%rdx
jae    1359 <main+0x219>
xor    %edx,%edx
xor    %ebx,%ebx
test   %rcx,%rcx
je     133b <main+0x1fb>
add    %rdx,%r14
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbq (%r14,%rdx,1),%rsi
mov    -0x184(%r15,%rsi,4),%esi
ff
cmp    %ebx,%esi
cmovg  %esi,%ebx
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1320 <main+0x1e0>
imul   %eax,%ebx
lea    0xcbb(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
and    $0xfffffffc,%esi
xor    %edx,%edx
xor    %ebx,%ebx
jmp    1379 <main+0x239>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x4,%rdx
cmp    %rdx,%rsi
je     1307 <main+0x1c7>
movsbq (%r14,%rdx,1),%rdi
mov    -0x184(%r15,%rdi,4),%edi
ff
cmp    %ebx,%edi
cmovg  %edi,%ebx
movsbq 0x1(%r14,%rdx,1),%rdi
mov    -0x184(%r15,%rdi,4),%edi
ff
cmp    %ebx,%edi
jg     139f <main+0x25f>
mov    %ebx,%edi
movsbq 0x2(%r14,%rdx,1),%rbp
mov    -0x184(%r15,%rbp,4),%ebp
ff
cmp    %edi,%ebp
jg     13b3 <main+0x273>
mov    %edi,%ebp
movsbq 0x3(%r14,%rdx,1),%rdi
mov    -0x184(%r15,%rdi,4),%ebx
ff
cmp    %ebp,%ebx
jg     1370 <main+0x230>
mov    %ebp,%ebx
jmp    1370 <main+0x230>

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 i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %5
%9 = call i32* @malloc(i32 104)
store i32* %9, i32** %6
store i32 0, i32* %7
br label %10
10: ; preds = %19, %0
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 26
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = load i32*, i32** %6
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %17)
br label %19
19: ; preds = %13
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
store i32 %21, i32* %7
br label %10
22: ; preds = %10
%23 = call i32* @malloc(i32 512000)
%24 = bitcast i32* %23 to i8*
store i8* %24, i8** %8
%25 = load i8*, i8** %8
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %8
%28 = call i32 @strlen(i8* %27)
store i32 %28, i32* %3
store i32 0, i32* %2
br label %29
29: ; preds = %55, %22
%30 = load i32, i32* %2
%31 = load i32, i32* %3
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %58
33: ; preds = %29
%34 = load i8*, i8** %8
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = sub nsw i32 %39, 97
store i32 %40, i32* %4
%41 = load i32*, i32** %6
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
%45 = load i32, i32* %44
%46 = load i32, i32* %5
%47 = icmp sgt i32 %45, %46
br i1 %47, label %48, label %54
48: ; preds = %33
%49 = load i32*, i32** %6
%50 = load i32, i32* %4
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %49, i64 %51
%53 = load i32, i32* %52
store i32 %53, i32* %5
br label %54
54: ; preds = %48, %33
br label %55
55: ; preds = %54
%56 = load i32, i32* %2
%57 = add nsw i32 %56, 1
store i32 %57, i32* %2
br label %29
58: ; preds = %29
%59 = load i32, i32* %5
%60 = load i32, i32* %3
%61 = mul nsw i32 %59, %60
%62 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %61)
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 = tail call i32* @malloc(i32 104)
%2 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%3 = getelementptr inbounds i32, i32* %1, i64 1
%4 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%5 = getelementptr inbounds i32, i32* %1, i64 2
%6 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%7 = getelementptr inbounds i32, i32* %1, i64 3
%8 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%9 = getelementptr inbounds i32, i32* %1, i64 4
%10 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%11 = getelementptr inbounds i32, i32* %1, i64 5
%12 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%13 = getelementptr inbounds i32, i32* %1, i64 6
%14 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
%15 = getelementptr inbounds i32, i32* %1, i64 7
%16 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %15)
%17 = getelementptr inbounds i32, i32* %1, i64 8
%18 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %17)
%19 = getelementptr inbounds i32, i32* %1, i64 9
%20 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %19)
%21 = getelementptr inbounds i32, i32* %1, i64 10
%22 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
%23 = getelementptr inbounds i32, i32* %1, i64 11
%24 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %23)
%25 = getelementptr inbounds i32, i32* %1, i64 12
%26 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %25)
%27 = getelementptr inbounds i32, i32* %1, i64 13
%28 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %27)
%29 = getelementptr inbounds i32, i32* %1, i64 14
%30 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %29)
%31 = getelementptr inbounds i32, i32* %1, i64 15
%32 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %31)
%33 = getelementptr inbounds i32, i32* %1, i64 16
%34 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %33)
%35 = getelementptr inbounds i32, i32* %1, i64 17
%36 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %35)
%37 = getelementptr inbounds i32, i32* %1, i64 18
%38 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %37)
%39 = getelementptr inbounds i32, i32* %1, i64 19
%40 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %39)
%41 = getelementptr inbounds i32, i32* %1, i64 20
%42 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %41)
%43 = getelementptr inbounds i32, i32* %1, i64 21
%44 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %43)
%45 = getelementptr inbounds i32, i32* %1, i64 22
%46 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %45)
%47 = getelementptr inbounds i32, i32* %1, i64 23
%48 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %47)
%49 = getelementptr inbounds i32, i32* %1, i64 24
%50 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %49)
%51 = getelementptr inbounds i32, i32* %1, i64 25
%52 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %51)
%53 = tail call i32* @malloc(i32 512000)
%54 = bitcast i32* %53 to i8*
%55 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %53)
%56 = tail call i32 @strlen(i8* %54)
%57 = icmp sgt i32 %56, 0
br i1 %57, label %58, label %127
58: ; preds = %0
%59 = zext i32 %56 to i64
%60 = add nsw i64 %59, -1
%61 = and i64 %59, 3
%62 = icmp ult i64 %60, 3
br i1 %62, label %107, label %63
63: ; preds = %58
%64 = and i64 %59, 4294967292
br label %65
65: ; preds = %65, %63
%66 = phi i64 [ 0, %63 ], [ %104, %65 ]
%67 = phi i32 [ 0, %63 ], [ %103, %65 ]
%68 = phi i64 [ 0, %63 ], [ %105, %65 ]
%69 = getelementptr inbounds i8, i8* %54, i64 %66
%70 = load i8, i8* %69
%71 = sext i8 %70 to i64
%72 = add nsw i64 %71, -97
%73 = getelementptr inbounds i32, i32* %1, i64 %72
%74 = load i32, i32* %73
%75 = icmp sgt i32 %74, %67
%76 = select i1 %75, i32 %74, i32 %67
%77 = or i64 %66, 1
%78 = getelementptr inbounds i8, i8* %54, i64 %77
%79 = load i8, i8* %78
%80 = sext i8 %79 to i64
%81 = add nsw i64 %80, -97
%82 = getelementptr inbounds i32, i32* %1, i64 %81
%83 = load i32, i32* %82
%84 = icmp sgt i32 %83, %76
%85 = select i1 %84, i32 %83, i32 %76
%86 = or i64 %66, 2
%87 = getelementptr inbounds i8, i8* %54, i64 %86
%88 = load i8, i8* %87
%89 = sext i8 %88 to i64
%90 = add nsw i64 %89, -97
%91 = getelementptr inbounds i32, i32* %1, i64 %90
%92 = load i32, i32* %91
%93 = icmp sgt i32 %92, %85
%94 = select i1 %93, i32 %92, i32 %85
%95 = or i64 %66, 3
%96 = getelementptr inbounds i8, i8* %54, i64 %95
%97 = load i8, i8* %96
%98 = sext i8 %97 to i64
%99 = add nsw i64 %98, -97
%100 = getelementptr inbounds i32, i32* %1, i64 %99
%101 = load i32, i32* %100
%102 = icmp sgt i32 %101, %94
%103 = select i1 %102, i32 %101, i32 %94
%104 = add nuw nsw i64 %66, 4
%105 = add i64 %68, 4
%106 = icmp eq i64 %105, %64
br i1 %106, label %107, label %65
107: ; preds = %65, %58
%108 = phi i32 [ undef, %58 ], [ %103, %65 ]
%109 = phi i64 [ 0, %58 ], [ %104, %65 ]
%110 = phi i32 [ 0, %58 ], [ %103, %65 ]
%111 = icmp eq i64 %61, 0
br i1 %111, label %127, label %112
112: ; preds = %107, %112
%113 = phi i64 [ %124, %112 ], [ %109, %107 ]
%114 = phi i32 [ %123, %112 ], [ %110, %107 ]
%115 = phi i64 [ %125, %112 ], [ 0, %107 ]
%116 = getelementptr inbounds i8, i8* %54, i64 %113
%117 = load i8, i8* %116
%118 = sext i8 %117 to i64
%119 = add nsw i64 %118, -97
%120 = getelementptr inbounds i32, i32* %1, i64 %119
%121 = load i32, i32* %120
%122 = icmp sgt i32 %121, %114
%123 = select i1 %122, i32 %121, i32 %114
%124 = add nuw nsw i64 %113, 1
%125 = add i64 %115, 1
%126 = icmp eq i64 %125, %61
br i1 %126, label %127, label %112
127: ; preds = %107, %112, %0
%128 = phi i32 [ 0, %0 ], [ %108, %107 ], [ %123, %112 ]
%129 = mul nsw i32 %128, %56
%130 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %129)
ret i32 0
}