while True:
    try:
        n,a,b,c = map(int,input().split())
        chars = input()
        dp = [0]*n
        for i in range(3,n):
            dp[i] = dp[i-1]
            if chars[i-3:i+1] == 'nico':
                dp[i] = max(dp[i],dp[i-4]+a)
            if i >= 5 and chars[i-5:i+1] == 'niconi':
                dp[i] = max(dp[i],dp[i-6]+b)
            if i >= 9 and chars[i-9:i+1] == 'niconiconi':
                dp[i] = max(dp[i],dp[i-10]+c)
        print(dp[-1])
    except:
        break