#include <bits/stdc++.h>

void update(std::set <std::pair <long long, int>> &q, long long *d, int startPos, int endPos, int cost) {
    if (d[endPos] > d[startPos] + cost) {
        q.erase(std::make_pair(d[endPos], endPos));
        d[endPos] = d[startPos] + cost;
        q.insert(std::make_pair(d[endPos], endPos));
    }
}

int main() {
    freopen("webbuy.in", "r", stdin);
    freopen("webbuy.out", "w", stdout);
    int n;
    scanf("%d", &n);
    char s[n + 1];
    scanf("%s", s);
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int f[n];
    f[0] = 0;
    for (int i = 1; i < n; i++) {
        int j = f[i - 1];
        while (j > 0 && s[i] != s[j])
            j = f[j - 1];
        if (s[i] == s[j])
            ++j;
        f[i] = j;
    }

    long long dp[2 * n + 1];
    for (int i = 1; i <= 2 * n; i++)
        dp[i] = 1e18;
    dp[0] = 0;          
    std::set <std::pair <long long, int>> q;
    q.insert(std::make_pair(0, 0));
    while (!q.empty()) {
        int i = q.begin()->second;
        q.erase(q.begin());
        if (i > 0)
            update(q, dp, i, i - 1, c);
        if (i < 2 * n)
            update(q, dp, i, i + 1, a);
        int end = std::min(n, 2 * i);
        int length = std::min(i, n - i);
        if (i > 0 && i < n && f[end - 1] >= length)
            update(q, dp, i, end, b);
    }
    printf("%I64d\n", dp[n]);
    return 0;
}