#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 *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);
  int len = strlen(word);
  int maxHeight = 0;
  for (int i = 0; i < len; i++) {
    if (h[word[i] - 'a'] > maxHeight) {
      maxHeight = h[word[i] - 'a'];
    }
  }
  printf("%d\n", maxHeight * len);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x68,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x1a,-0x14(%rbp)
jge    1199 <main+0x59>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1164 <main+0x24>
mov    $0x7d000,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1230 <main+0xf0>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
sub    $0x61,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x28(%rbp),%eax
jle    121d <main+0xdd>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
sub    $0x61,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x28(%rbp)
jmp    1222 <main+0xe2>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d3 <main+0x93>
mov    -0x28(%rbp),%esi
imul   -0x24(%rbp),%esi
lea    0xdc8(%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    0xcc1(%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"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32* @malloc(i32 104)
store i32* %8, i32** %2
store i32 0, i32* %3
br label %9
9: ; preds = %18, %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 26
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = load i32*, i32** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %16)
br label %18
18: ; preds = %12
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %9
21: ; preds = %9
%22 = call i32* @malloc(i32 512000)
%23 = bitcast i32* %22 to i8*
store i8* %23, i8** %4
%24 = load i8*, i8** %4
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = load i8*, i8** %4
%27 = call i32 @strlen(i8* %26)
store i32 %27, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %28
28: ; preds = %59, %21
%29 = load i32, i32* %7
%30 = load i32, i32* %5
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %62
32: ; preds = %28
%33 = load i32*, i32** %2
%34 = load i8*, i8** %4
%35 = load i32, i32* %7
%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
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %33, i64 %41
%43 = load i32, i32* %42
%44 = load i32, i32* %6
%45 = icmp sgt i32 %43, %44
br i1 %45, label %46, label %58
46: ; preds = %32
%47 = load i32*, i32** %2
%48 = load i8*, i8** %4
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = sub nsw i32 %53, 97
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* %47, i64 %55
%57 = load i32, i32* %56
store i32 %57, i32* %6
br label %58
58: ; preds = %46, %32
br label %59
59: ; preds = %58
%60 = load i32, i32* %7
%61 = add nsw i32 %60, 1
store i32 %61, i32* %7
br label %28
62: ; preds = %28
%63 = load i32, i32* %6
%64 = load i32, i32* %5
%65 = mul nsw i32 %63, %64
%66 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %65)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"%d\0A\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 %85
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 %65, label %63
63: ; preds = %58
%64 = and i64 %59, 4294967292
br label %89
65: ; preds = %89, %58
%66 = phi i32 [ undef, %58 ], [ %127, %89 ]
%67 = phi i64 [ 0, %58 ], [ %128, %89 ]
%68 = phi i32 [ 0, %58 ], [ %127, %89 ]
%69 = icmp eq i64 %61, 0
br i1 %69, label %85, label %70
70: ; preds = %65, %70
%71 = phi i64 [ %82, %70 ], [ %67, %65 ]
%72 = phi i32 [ %81, %70 ], [ %68, %65 ]
%73 = phi i64 [ %83, %70 ], [ 0, %65 ]
%74 = getelementptr inbounds i8, i8* %54, i64 %71
%75 = load i8, i8* %74
%76 = sext i8 %75 to i64
%77 = add nsw i64 %76, -97
%78 = getelementptr inbounds i32, i32* %1, i64 %77
%79 = load i32, i32* %78
%80 = icmp sgt i32 %79, %72
%81 = select i1 %80, i32 %79, i32 %72
%82 = add nuw nsw i64 %71, 1
%83 = add i64 %73, 1
%84 = icmp eq i64 %83, %61
br i1 %84, label %85, label %70
85: ; preds = %65, %70, %0
%86 = phi i32 [ 0, %0 ], [ %66, %65 ], [ %81, %70 ]
%87 = mul nsw i32 %86, %56
%88 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %87)
ret i32 0
89: ; preds = %89, %63
%90 = phi i64 [ 0, %63 ], [ %128, %89 ]
%91 = phi i32 [ 0, %63 ], [ %127, %89 ]
%92 = phi i64 [ 0, %63 ], [ %129, %89 ]
%93 = getelementptr inbounds i8, i8* %54, i64 %90
%94 = load i8, i8* %93
%95 = sext i8 %94 to i64
%96 = add nsw i64 %95, -97
%97 = getelementptr inbounds i32, i32* %1, i64 %96
%98 = load i32, i32* %97
%99 = icmp sgt i32 %98, %91
%100 = select i1 %99, i32 %98, i32 %91
%101 = or i64 %90, 1
%102 = getelementptr inbounds i8, i8* %54, i64 %101
%103 = load i8, i8* %102
%104 = sext i8 %103 to i64
%105 = add nsw i64 %104, -97
%106 = getelementptr inbounds i32, i32* %1, i64 %105
%107 = load i32, i32* %106
%108 = icmp sgt i32 %107, %100
%109 = select i1 %108, i32 %107, i32 %100
%110 = or i64 %90, 2
%111 = getelementptr inbounds i8, i8* %54, i64 %110
%112 = load i8, i8* %111
%113 = sext i8 %112 to i64
%114 = add nsw i64 %113, -97
%115 = getelementptr inbounds i32, i32* %1, i64 %114
%116 = load i32, i32* %115
%117 = icmp sgt i32 %116, %109
%118 = select i1 %117, i32 %116, i32 %109
%119 = or i64 %90, 3
%120 = getelementptr inbounds i8, i8* %54, i64 %119
%121 = load i8, i8* %120
%122 = sext i8 %121 to i64
%123 = add nsw i64 %122, -97
%124 = getelementptr inbounds i32, i32* %1, i64 %123
%125 = load i32, i32* %124
%126 = icmp sgt i32 %125, %118
%127 = select i1 %126, i32 %125, i32 %118
%128 = add nuw nsw i64 %90, 4
%129 = add i64 %92, 4
%130 = icmp eq i64 %129, %64
br i1 %130, label %65, label %89
}