#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if (a[i].speed.y > 0 && a[i].a.y <= maxY) a[i].a.y = maxY;
        if (a[i].speed.y < 0 && a[i].a.y >= maxY) a[i].a.y = maxY;

        if (a[i].speed.x > 0 && a[i].a.x <= maxX) a[i].a.x = maxX;
        if (a[i].speed.x < 0 && a[i].a.x >= maxX) a[i].a.x = maxX;

        if ((a[i].a.y <= maxY || a[i].a.y >= minY) && a[i].speed.x == 0 && (a[i].a.x == maxX || a[i].a.x == minX)){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x <= maxX || a[i].a.x >= minX) && a[i].speed.y == 0 && (a[i].a.y == maxY || a[i].a.y == minY)){
            cout << -1;
            return 0;
        }

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time + 0.000000000001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time - 0.00000001, -1});
    }

    int status = 0;

    sort(sl.begin(), sl.end());

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if ((a[i].a.y <= maxY || a[i].a.y >= minY) && a[i].speed.x == 0 && (a[i].a.x == maxX || a[i].a.x == minX)){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x <= maxX || a[i].a.x >= minX) && a[i].speed.y == 0 && (a[i].a.y == maxY || a[i].a.y == minY)){
            cout << -1;
            return 0;
        }

        if ((a[i].a.y == maxY || a[i].a.y == minY) && a[i].speed.y < 0 && a[i].a.y >= maxY && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        if ((a[i].a.y == maxY || a[i].a.y == minY) && a[i].speed.y > 0 && a[i].a.y <= minY && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x == maxX || a[i].a.x == minX) && a[i].speed.x < 0 && a[i].a.x >= maxX && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x == maxX || a[i].a.x == minX) && a[i].speed.x > 0 && a[i].a.x <= minX && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time + 0.000000000001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00000001, -1});
    }

    int status = 0;

    sort(sl.begin(), sl.end());

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if (a[i].a.x == maxX && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        if (a[i].a.x == minX && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        if (a[i].a.y == maxY && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        if (a[i].a.y == minY && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        //cout << min_x << ' ' << max_x << "     " << min_y << ' ' << max_y << endl;

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        //cout << min_time << ' ' << max_time << endl;

        if (min_time + 0.000000000001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00000001, -1});
    }

    int status = 0;

    sort(sl.begin(), sl.end());

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if ((a[i].a.y <= maxY || a[i].a.y >= minY) && a[i].speed.x == 0 && (a[i].a.x == maxX || a[i].a.x == minX)){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x <= maxX || a[i].a.x >= minX) && a[i].speed.y == 0 && (a[i].a.y == maxY || a[i].a.y == minY)){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x <= maxX && a[i].a.x >= minX) && a[i].speed.y < 0 && a[i].a.y >= maxY && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x <= maxX && a[i].a.x >= minX) && a[i].speed.y > 0 && a[i].a.y <= minY && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        if ((a[i].a.y <= maxY && a[i].a.y >= minY) && a[i].speed.x < 0 && a[i].a.x >= maxX && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        if ((a[i].a.y <= maxY && a[i].a.y >= minY) && a[i].speed.x > 0 && a[i].a.x <= minX && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);

        double max_time = min(max_x, max_y);

        if (min_time + 0.000000000001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00000001, -1});
    }

    int status = 0;

    sort(sl.begin(), sl.end());

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
            else r = m;
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
            else r = m;
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
            else r = m;
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
            else r = m;
        }

        max_y = l;

        //

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time + 0.00001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time, -1});
    }

    int status = 0;

    sort(sl.begin(), sl.end());

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if ((a[i].a.y <= maxY || a[i].a.y >= minY) && a[i].speed.x == 0 && (a[i].a.x == maxX || a[i].a.x == minX)){
            cout << -1;
            return 0;
        }

        if ((a[i].a.x <= maxX || a[i].a.x >= minX) && a[i].speed.y == 0 && (a[i].a.y == maxY || a[i].a.y == minY)){
            cout << -1;
            return 0;
        }

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time + 0.000000000001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00000001, -1});
    }

    int status = 0;

    sort(sl.begin(), sl.end());

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        //cout << min_x << ' ' << max_x << "     " << min_y << ' ' << max_y << endl;

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        //cout << min_time << ' ' << max_time << endl;

        if (min_time + 0.000000000001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time - 0.00000001, 1});
        sl.push_back({max_time + 0.00000001, -1});
    }

    int status = 0;

    sort(sl.begin(), sl.end());

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        //cout << min_x << ' ' << max_x << "     " << min_y << ' ' << max_y << endl;

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        if (min_time + 0.00001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time - 0.00000001, 1});
        sl.push_back({max_time + 0.00000001, -1});
    }

    int status = 0;

    sort(sl.begin(), sl.end());

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <bits/stdc++.h>

using namespace std;

void Draganov47(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
}

struct pt {
    double x, y;
};

struct vc {
    double x, y;
};

vc gv(pt a, pt b) {
    return {b.x - a.x, b.y - a.y};
}

double ks(vc a, vc b) {
    return (a.x * b.y) - (a.y * b.x);
}

double sc(vc a, vc b) {
    return (a.x + b.x) - (a.y + b.y);
}

const int MAX = 1e5 + 47;

struct mause{
    pt a, b, speed;
};

int n;

pt f, s;

mause a[MAX];

int main(){
    Draganov47();

    cin >> n;

    cin >> f.x >> f.y >> s.x >> s.y;

    double maxX = max(f.x, s.x);
    double minX = min(f.x, s.x);
    double maxY = max(f.y, s.y);
    double minY = min(f.y, s.y);

    vector < pair <double, int> > sl;

    for (int i = 1; i <= n; i++) cin >> a[i].a.x >> a[i].a.y >> a[i].speed.x >> a[i].speed.y;
    for (int i = 1; i <= n; i++){

        double min_x = -1, max_x = -1;

        //

        double l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= minX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= minX) r = m;
                else l = m;
            }
        }

        min_x = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.x > 0){
                if (m * a[i].speed.x + a[i].a.x <= maxX) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.x + a[i].a.x <= maxX) r = m;
                else l = m;
            }
        }

        max_x = l;

        double min_y = -1, max_y = -1;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= minY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= minY) r = m;
                else l = m;
            }
        }

        min_y = l;

        l = 0, r = 1e6;

        for (int z = 1; z <= 100; z++){
            double m = (l + r) / 2.0;
            if (a[i].speed.y > 0){
                if (m * a[i].speed.y + a[i].a.y <= maxY) l = m;
                else r = m;
            }
            else {
                if (m * a[i].speed.y + a[i].a.y <= maxY) r = m;
                else l = m;
            }
        }

        max_y = l;

        //

        if (a[i].a.y <= maxY && a[i].a.y >= minY && a[i].speed.x == 0){
            cout << -1;
            return 0;
        }

        if (a[i].a.x <= maxX && a[i].a.x >= minX && a[i].speed.y == 0){
            cout << -1;
            return 0;
        }

        //cout << min_x << ' ' << max_x << "     " << min_y << ' ' << max_y << endl;

        if (max_y < min_y) swap(max_y, min_y);

        if (max_x < min_x) swap(max_x, min_x);

        double min_time = max(min_x, min_y);
        double max_time = min(max_x, max_y);

        //cout << min_time << ' ' << max_time << endl;

        if (min_time + 0.000000000001 > max_time){
            cout << -1;
            return 0;
        }

        sl.push_back({min_time, 1});
        sl.push_back({max_time + 0.00000001, -1});
    }

    int status = 0;

    sort(sl.begin(), sl.end());

    for (int i = 0; i < sl.size(); i++){
        status += sl[i].second;
        if (status == n){
            cout << sl[i].first;
            return 0;
        }
    }

    cout << -1;
}


#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

const int MAXN = 1e3 * 5 + 5;
const int BASE1 = 256, BASE2 = 257, BASE3 = 258;
const int MOD1 = 1e6 + 9, MOD2 = 1e9 + 3, MOD3 = 1e9 + 9;
const int INF = 1e9;

int add(int f, int s, int mod)
{
    f += s;
    return f % mod;
}

//int f[3][MAXN];

int mul(int f, int s, int mod)
{
    long long temp = 1LL * f * s;
    temp %= mod;
    return temp;
}

int sub(int f, int s, int mod)
{
    f -= s;
    if(f < 0) f += mod;
    return f;
}

struct Hash
{
    int h1, h2, h3;
    int index;
    Hash()
    {
        index = INF;
        h1 = 0; h2 = 0; h3 = 0;
    }

    void append(int l)
    {
        h1 = add(mul(h1, BASE1, MOD1), l, MOD1);
        h2 = add(mul(h2, BASE2, MOD2), l, MOD2);
        h3 = add(mul(h3, BASE3, MOD3), l, MOD3);
    }

    /*void mult(int len)
    {
        //h1 = mul(h1, f[0][len], MOD1);
        //h2 = mul(h2, f[1][len], MOD2);
        //h3 = mul(h3, f[2][len], MOD3);
    }*/

    bool operator==(Hash other) const
    {
        return (h1 == other.h1) && (h2 == other.h2) && (h3 == other.h3);
    }
    bool operator<(Hash other) const
    {
        return h1 < other.h1 || (h1 == other.h1 && h2 < other.h2) || (h1 == other.h1 && h2 == other.h2 && h3 < other.h3) || (h1 == other.h1 && h2 == other.h2 && h3 == other.h3 && index < other.index);
    }
};

int cmp(Hash f, Hash other)
{
    if(f.h1 < other.h1)
    {
        return 1;
    }
    if(f.h1 > other.h1)
    {
        return 0;
    }
    if(f.h2 < other.h2)
    {
        return 1;
    }
    if(f.h2 > other.h2)
    {
        return 0;
    }
    if(f.h3 < other.h3)
    {
        return 1;
    }
    if(f.h3 > other.h3)
    {
        return 0;
    }
    return 2;
}

int n, a, b, k;
short str[MAXN];
int T[MAXN];
//Hash tree[MAXN];

/*Hash query(int l, int r)
{
    if(l == 0) return tree[r];
    Hash f = tree[r];
    Hash h = tree[l - 1];
    h.mult(r - l);
    //printf("~%d %d\n", h.h1, tree[l - 1].h1);

    f.h1 = sub(f.h1, h.h1, MOD1);
    f.h2 = sub(f.h2, h.h2, MOD2);

    return f;
}*/

void read_input()
{
    scanf("%d %d %d", &n, &a, &b);

    short cr;
    for(int i = 0; i < n; i++)
    {
        scanf(" %c", &cr);
        str[i] = cr;
    }
}

vector <Hash> arr;

set <Hash> vis[MOD1];

int bin_search(Hash temp)
{
    int l = 0, r = k - 1;

    while(l <= r)
    {
        int mid = (l + r) / 2;

        int cmpa = cmp(arr[mid], temp);
        //printf("%d %d %d %d\n", mid, temp.h1, arr[mid].h1, cmpa);

        if(cmpa == 0)
        {
            r = mid - 1;
        }
        else if(cmpa == 1)
        {
            l = mid + 1;
        }
        else
        {
            //printf("%d\n", mid);
            return arr[mid].index;
        }
    }
    return 0;
}

int rec(int index)
{
    if(index == n)
    {
        return 0;
    }
    if(T[index])
    {
        return T[index];
    }
    int ans = INF;

    Hash temp;
    int j = index;
    while(j < n)
    {
        temp.append(str[j]);
        //temp = query(index, j);
        //printf("%d %d\n", temp.h1, query(index, j));

        int ind = bin_search(temp);
        //printf("%d %d %d %d\n", temp.h1, temp.h2, temp.h3, ind);

        if(ind != 0 && ind - 1 < index)
        {
            ans = min(ans, rec(j + 1) + b);
        }
        j++;
    }
    ans = min(ans, rec(index + 1) + a);

    return T[index] = ans;
}

void precomp()
{
    /*f[0][0] = BASE1; f[1][0] = BASE2; f[2][0] = BASE3;

    for(int i = 1; i <= n; i++)
    {
        f[0][i] = mul(BASE1, f[0][i - 1], MOD1);
        f[1][i] = mul(BASE2, f[1][i - 1], MOD2);
        f[2][i] = mul(BASE3, f[2][i - 1], MOD3);
    }

    tree[0].append(str[0]);
    for(int i = 1; i < n; i++)
    {
        tree[i] = tree[i - 1];
        tree[i].append(str[i]);
    }*/
    int cnt = 0;
    for(int i = 0; i < n; i++)
    {
        Hash temp;
        for(int j = i; j < n;j++)
        {
            temp.append(str[j]);
            temp.index = j + 1;
            //printf("%d %d %d\n", i, j, temp.h1);

            if(!vis[temp.h1].count(temp))
            {
                vis[temp.h1].insert(temp);
                arr.push_back(temp);
                cnt++;
            }
        }
    }
    sort(arr.begin(), arr.end());
    int temp = 0;

    for(int i = 0; i < cnt; i++)
    {
        arr[temp++] = arr[i];
        int j = i + 1;
        while(j < cnt && arr[i] == arr[j])
        {
            j++;
        }
        i = j - 1;
    }
    k = temp;
}

void solve()
{
    printf("%d\n", rec(0));
}

int main()
{
    read_input();
    precomp();
    solve();

    return 0;
}


#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

const int MAXN = 1e3 * 5 + 5;
const int BASE1 = 256, BASE2 = 257, BASE3 = 258;
const int MOD1 = 1e9 + 7, MOD2 = 1e9 + 3, MOD3 = 1e9 + 9;
const int INF = 1e9;

int add(int f, int s, int mod)
{
    f += s;
    return f % mod;
}

int f[3][MAXN];

int mul(int f, int s, int mod)
{
    long long temp = 1LL * f * s;
    temp %= mod;
    return temp;
}

int sub(int f, int s, int mod)
{
    f -= s;
    if(f < 0) f += mod;
    return f;
}

struct Hash
{
    int h1, h2/*, h3*/;
    int index;
    Hash()
    {
        index = INF;
        h1 = 0; h2 = 0;/* h3 = 0;*/
    }

    void append(int l)
    {
        h1 = add(mul(h1, BASE1, MOD1), l, MOD1);
        h2 = add(mul(h2, BASE2, MOD2), l, MOD2);
        //h3 = add(mul(h3, BASE3, MOD3), l, MOD3);
    }

    void mult(int len)
    {
        h1 = mul(h1, f[0][len], MOD1);
        h2 = mul(h2, f[1][len], MOD2);
        //h3 = mul(h3, f[2][len], MOD3);
    }

    bool operator==(Hash other) const
    {
        return (h1 == other.h1) && (h2 == other.h2) /*&& (h3 == other.h3)*/;
    }
    bool operator<(Hash other) const
    {
        return h1 < other.h1 || (h1 == other.h1 && h2 < other.h2) && (h1 == other.h1 && h2 == other.h2 && index < other.index)/* || (h1 == other.h1 && h2 == other.h2 && h3 < other.h3) || (h1 == other.h1 && h2 == other.h2 && h3 == other.h3 && index < other.index)*/;
    }
};

int cmp(Hash f, Hash other)
{
    if(f.h1 < other.h1)
    {
        return 1;
    }
    if(f.h1 > other.h1)
    {
        return 0;
    }
    if(f.h2 < other.h2)
    {
        return 1;
    }
    if(f.h2 > other.h2)
    {
        return 0;
    }
    /*if(f.h3 < other.h3)
    {
        return 1;
    }
    if(f.h3 > other.h3)
    {
        return 0;
    }*/
    return 2;
}

int n, a, b, k;
char str[MAXN];
int T[MAXN];
Hash tree[MAXN];

Hash query(int l, int r)
{
    if(l == 0) return tree[r];
    Hash f = tree[r];
    Hash h = tree[l - 1];
    h.mult(r - l);
    //printf("~%d %d\n", h.h1, tree[l - 1].h1);

    f.h1 = sub(f.h1, h.h1, MOD1);
    f.h2 = sub(f.h2, h.h2, MOD2);
    //f.h3 = sub(f.h3, h.h3, MOD3);

    return f;
}

void read_input()
{
    scanf("%d %d %d", &n, &a, &b);

    scanf("%s", str);
}
vector <Hash> arr;

int bin_search(Hash temp)
{
    int l = 0, r = k - 1;

    while(l <= r)
    {
        int mid = (l + r) / 2;

        int cmpa = cmp(arr[mid], temp);
        //printf("%d %d %d %d\n", mid, temp.h1, arr[mid].h1, cmpa);

        if(cmpa == 0)
        {
            r = mid - 1;
        }
        else if(cmpa == 1)
        {
            l = mid + 1;
        }
        else
        {
            //printf("%d\n", mid);
            return arr[mid].index;
        }
    }
    return 0;
}

int rec(int index)
{
    if(index == n)
    {
        return 0;
    }
    if(T[index])
    {
        return T[index];
    }
    int ans = INF;

    Hash temp;
    int j = index;
    while(j < n)
    {
        temp = query(index, j);
        //printf("%d %d\n", temp.h1, query(index, j));

        int ind = bin_search(temp);
        //printf("%d %d %d %d\n", temp.h1, temp.h2, temp.h3, ind);

        if(ind != 0 && ind - 1 < index)
        {
            ans = min(ans, rec(j + 1) + b);
        }
        j++;
    }
    ans = min(ans, rec(index + 1) + a);

    return T[index] = ans;
}

void precomp()
{
    f[0][0] = BASE1; f[1][0] = BASE2; f[2][0] = BASE3;

    for(int i = 1; i <= n; i++)
    {
        f[0][i] = mul(BASE1, f[0][i - 1], MOD1);
        f[1][i] = mul(BASE2, f[1][i - 1], MOD2);
        f[2][i] = mul(BASE3, f[2][i - 1], MOD3);
    }

    tree[0].append(str[0]);
    for(int i = 1; i < n; i++)
    {
        tree[i] = tree[i - 1];
        tree[i].append(str[i]);
    }
    int cnt = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = i; j < n;j++)
        {
            Hash temp = query(i, j);
            temp.index = j + 1;
            //printf("%d %d %d\n", i, j, temp.h1);
            arr.push_back(temp);
            cnt++;
        }
    }
    sort(arr.begin(), arr.end());
    int temp = 0;
    for(int i = 0; i < cnt; i++)
    {
        arr[temp++] = arr[i];
        int j = i + 1;
        while(j < cnt && arr[i] == arr[j])
        {
            j++;
        }
        i = j - 1;
    }
    k = temp;
}

void solve()
{
    printf("%d\n", rec(0));
}

int main()
{
    read_input();
    precomp();
    solve();

    return 0;
}


#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

const int MAXN = 1e3 * 5 + 5;
const int BASE1 = 256, BASE2 = 257, BASE3 = 258;
const int MOD1 = 1e6 + 7, MOD2 = 1e9 + 3, MOD3 = 1e9 + 9;
const int INF = 1e9;

int add(int f, int s, int mod)
{
    f += s;
    return f % mod;
}

//int f[3][MAXN];

int mul(int f, int s, int mod)
{
    long long temp = 1LL * f * s;
    temp %= mod;
    return temp;
}

int sub(int f, int s, int mod)
{
    f -= s;
    if(f < 0) f += mod;
    return f;
}

struct Hash
{
    int h1, h2, h3;
    int index;
    Hash()
    {
        index = INF;
        h1 = 0; h2 = 0; h3 = 0;
    }

    void append(int l)
    {
        h1 = add(mul(h1, BASE1, MOD1), l, MOD1);
        h2 = add(mul(h2, BASE2, MOD2), l, MOD2);
        h3 = add(mul(h3, BASE3, MOD3), l, MOD3);
    }

    /*void mult(int len)
    {
        //h1 = mul(h1, f[0][len], MOD1);
        //h2 = mul(h2, f[1][len], MOD2);
        //h3 = mul(h3, f[2][len], MOD3);
    }*/

    bool operator==(Hash other) const
    {
        return (h1 == other.h1) && (h2 == other.h2) && (h3 == other.h3);
    }
    bool operator<(Hash other) const
    {
        return h1 < other.h1 || (h1 == other.h1 && h2 < other.h2) || (h1 == other.h1 && h2 == other.h2 && h3 < other.h3) || (h1 == other.h1 && h2 == other.h2 && h3 == other.h3 && index < other.index);
    }
};

int cmp(Hash f, Hash other)
{
    if(f.h1 < other.h1)
    {
        return 1;
    }
    if(f.h1 > other.h1)
    {
        return 0;
    }
    if(f.h2 < other.h2)
    {
        return 1;
    }
    if(f.h2 > other.h2)
    {
        return 0;
    }
    if(f.h3 < other.h3)
    {
        return 1;
    }
    if(f.h3 > other.h3)
    {
        return 0;
    }
    return 2;
}

int n, a, b, k;
short str[MAXN];
int T[MAXN];
//Hash tree[MAXN];

/*Hash query(int l, int r)
{
    if(l == 0) return tree[r];
    Hash f = tree[r];
    Hash h = tree[l - 1];
    h.mult(r - l);
    //printf("~%d %d\n", h.h1, tree[l - 1].h1);

    f.h1 = sub(f.h1, h.h1, MOD1);
    f.h2 = sub(f.h2, h.h2, MOD2);

    return f;
}*/

void read_input()
{
    scanf("%d %d %d", &n, &a, &b);

    short cr;
    for(int i = 0; i < n; i++)
    {
        scanf(" %c", &cr);
        str[i] = cr;
    }
}

vector <Hash> arr;

bool vis[MOD1];

int bin_search(Hash temp)
{
    int l = 0, r = k - 1;

    while(l <= r)
    {
        int mid = (l + r) / 2;

        int cmpa = cmp(arr[mid], temp);
        //printf("%d %d %d %d\n", mid, temp.h1, arr[mid].h1, cmpa);

        if(cmpa == 0)
        {
            r = mid - 1;
        }
        else if(cmpa == 1)
        {
            l = mid + 1;
        }
        else
        {
            //printf("%d\n", mid);
            return arr[mid].index;
        }
    }
    return 0;
}

int rec(int index)
{
    if(index == n)
    {
        return 0;
    }
    if(T[index])
    {
        return T[index];
    }
    int ans = INF;

    Hash temp;
    int j = index;
    while(j < n)
    {
        temp.append(str[j]);
        //temp = query(index, j);
        //printf("%d %d\n", temp.h1, query(index, j));

        int ind = bin_search(temp);
        //printf("%d %d %d %d\n", temp.h1, temp.h2, temp.h3, ind);

        if(ind != 0 && ind - 1 < index)
        {
            ans = min(ans, rec(j + 1) + b);
        }
        j++;
    }
    ans = min(ans, rec(index + 1) + a);

    return T[index] = ans;
}

void precomp()
{
    /*f[0][0] = BASE1; f[1][0] = BASE2; f[2][0] = BASE3;

    for(int i = 1; i <= n; i++)
    {
        f[0][i] = mul(BASE1, f[0][i - 1], MOD1);
        f[1][i] = mul(BASE2, f[1][i - 1], MOD2);
        f[2][i] = mul(BASE3, f[2][i - 1], MOD3);
    }

    tree[0].append(str[0]);
    for(int i = 1; i < n; i++)
    {
        tree[i] = tree[i - 1];
        tree[i].append(str[i]);
    }*/
    int cnt = 0;
    for(int i = 0; i < n; i++)
    {
        Hash temp;
        for(int j = i; j < n;j++)
        {
            temp.append(str[j]);
            temp.index = j + 1;
            //printf("%d %d %d\n", i, j, temp.h1);
            if(!vis[temp.h1])
            {
                arr.push_back(temp);
                vis[temp.h1] = true;
                cnt++;
            }
        }
    }
    sort(arr.begin(), arr.end());
    int temp = 0;
    for(int i = 0; i < cnt; i++)
    {
        arr[temp++] = arr[i];
        int j = i + 1;
        while(j < cnt && arr[i] == arr[j])
        {
            j++;
        }
        i = j - 1;
    }
    k = temp;
    arr.resize(k);
}

void solve()
{
    printf("%d\n", rec(0));
}

int main()
{
    read_input();
    precomp();
    solve();

    return 0;
}


#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

const int MAXN = 1e3 * 5 + 5;
const int BASE1 = 256, BASE2 = 257, BASE3 = 258;
const int MOD1 = 1e6 + 9, MOD2 = 1e9 + 3, MOD3 = 1e9 + 9;
const int INF = 1e9;

int add(int f, int s, int mod)
{
    f += s;
    return f % mod;
}

//int f[3][MAXN];

int mul(int f, int s, int mod)
{
    long long temp = 1LL * f * s;
    temp %= mod;
    return temp;
}

int sub(int f, int s, int mod)
{
    f -= s;
    if(f < 0) f += mod;
    return f;
}

struct Hash
{
    int h1, h2, h3;
    int index;
    Hash()
    {
        index = INF;
        h1 = 0; h2 = 0; h3 = 0;
    }

    void append(int l)
    {
        h1 = add(mul(h1, BASE1, MOD1), l, MOD1);
        h2 = add(mul(h2, BASE2, MOD2), l, MOD2);
        h3 = add(mul(h3, BASE3, MOD3), l, MOD3);
    }

    /*void mult(int len)
    {
        //h1 = mul(h1, f[0][len], MOD1);
        //h2 = mul(h2, f[1][len], MOD2);
        //h3 = mul(h3, f[2][len], MOD3);
    }*/

    bool operator==(Hash other) const
    {
        return (h1 == other.h1) && (h2 == other.h2) && (h3 == other.h3);
    }
    bool operator<(Hash other) const
    {
        return h1 < other.h1 || (h1 == other.h1 && h2 < other.h2) || (h1 == other.h1 && h2 == other.h2 && h3 < other.h3) || (h1 == other.h1 && h2 == other.h2 && h3 == other.h3 && index < other.index);
    }
};

int cmp(Hash f, Hash other)
{
    if(f.h1 < other.h1)
    {
        return 1;
    }
    if(f.h1 > other.h1)
    {
        return 0;
    }
    if(f.h2 < other.h2)
    {
        return 1;
    }
    if(f.h2 > other.h2)
    {
        return 0;
    }
    if(f.h3 < other.h3)
    {
        return 1;
    }
    if(f.h3 > other.h3)
    {
        return 0;
    }
    return 2;
}

int n, a, b, k;
short str[MAXN];
int T[MAXN];
//Hash tree[MAXN];

/*Hash query(int l, int r)
{
    if(l == 0) return tree[r];
    Hash f = tree[r];
    Hash h = tree[l - 1];
    h.mult(r - l);
    //printf("~%d %d\n", h.h1, tree[l - 1].h1);

    f.h1 = sub(f.h1, h.h1, MOD1);
    f.h2 = sub(f.h2, h.h2, MOD2);

    return f;
}*/

void read_input()
{
    scanf("%d %d %d", &n, &a, &b);

    short cr;
    for(int i = 0; i < n; i++)
    {
        scanf(" %c", &cr);
        str[i] = cr;
    }
}

vector <Hash> arr;

bool vis[MOD1];

int bin_search(Hash temp)
{
    int l = 0, r = k - 1;

    while(l <= r)
    {
        int mid = (l + r) / 2;

        int cmpa = cmp(arr[mid], temp);
        //printf("%d %d %d %d\n", mid, temp.h1, arr[mid].h1, cmpa);

        if(cmpa == 0)
        {
            r = mid - 1;
        }
        else if(cmpa == 1)
        {
            l = mid + 1;
        }
        else
        {
            //printf("%d\n", mid);
            return arr[mid].index;
        }
    }
    return 0;
}

int rec(int index)
{
    if(index == n)
    {
        return 0;
    }
    if(T[index])
    {
        return T[index];
    }
    int ans = INF;

    Hash temp;
    int j = index;
    while(j < n)
    {
        temp.append(str[j]);
        //temp = query(index, j);
        //printf("%d %d\n", temp.h1, query(index, j));

        int ind = bin_search(temp);
        //printf("%d %d %d %d\n", temp.h1, temp.h2, temp.h3, ind);

        if(ind != 0 && ind - 1 < index)
        {
            ans = min(ans, rec(j + 1) + b);
        }
        j++;
    }
    ans = min(ans, rec(index + 1) + a);

    return T[index] = ans;
}

void precomp()
{
    /*f[0][0] = BASE1; f[1][0] = BASE2; f[2][0] = BASE3;

    for(int i = 1; i <= n; i++)
    {
        f[0][i] = mul(BASE1, f[0][i - 1], MOD1);
        f[1][i] = mul(BASE2, f[1][i - 1], MOD2);
        f[2][i] = mul(BASE3, f[2][i - 1], MOD3);
    }

    tree[0].append(str[0]);
    for(int i = 1; i < n; i++)
    {
        tree[i] = tree[i - 1];
        tree[i].append(str[i]);
    }*/
    int cnt = 0;
    for(int i = 0; i < n; i++)
    {
        Hash temp;
        for(int j = i; j < n;j++)
        {
            temp.append(str[j]);
            temp.index = j + 1;
            //printf("%d %d %d\n", i, j, temp.h1);
            if(!vis[temp.h1])
            {
                arr.push_back(temp);
                vis[temp.h1] = true;
                cnt++;
            }
        }
    }
    sort(arr.begin(), arr.end());
    int temp = 0;
    for(int i = 0; i < cnt; i++)
    {
        arr[temp++] = arr[i];
        int j = i + 1;
        while(j < cnt && arr[i] == arr[j])
        {
            j++;
        }
        i = j - 1;
    }
    k = temp;
    arr.resize(k);
}

void solve()
{
    printf("%d\n", rec(0));
}

int main()
{
    read_input();
    precomp();
    solve();

    return 0;
}


#include <cstdio>
#include <algorithm>

using namespace std;

const int MAXN = 1e3 * 5 + 5;
const int BASE1 = 256, BASE2 = 257, BASE3 = 258;
const int MOD1 = 1e9 + 7, MOD2 = 1e9 + 3, MOD3 = 1e9 + 9;
const int INF = 1e9;

int n, a, b, k;
char str[MAXN];
int T[MAXN];
int z[MAXN];
char pat[MAXN];

void read_input()
{
    scanf("%d %d %d", &n, &a, &b);

    scanf("%s", str);
}

void z_function(int len)
{
    for(int i = 0; i < len; i++)
    {
        z[i] = 0;
    }
    for(int i = 1, l = 0, r = 0; i < len; i++)
    {
        if(i <= r)
        {
            z[i] = min(z[i - l], r - i + 1);
        }
        while(z[i] + i < len && pat[z[i]] == pat[i + z[i]])
        {
            z[i]++;
        }
        if(z[i] + i - 1> r)
        {
            r = z[i] + i - 1;
            l = i;
        }
    }
}

int rec(int index)
{
    if(index > n)
    {
        return INF;
    }
    if(index == n)
    {
        return 0;
    }
    if(T[index])
    {
        return T[index];
    }
    int ans = INF;

    int l = 0;
    int from = 0;
    for(int i = index; i < n; i++)
    {
        pat[l++] = str[i];
    }
    pat[l++] = '#';
    from = l;
    for(int i = 0; i < index; i++)
    {
        pat[l++] = str[i];
    }
    z_function(l);

    int ind = 0;
    for(int i = from; i < l; i++)
    {
        //printf("%d\n", z[0]);
        ind = max(ind, z[i]);
    }
    //printf("%d", index);

    for(int i = 0; i < ind; i++)
    {
        ans = min(ans, rec(index + i + 1) + b);
    }

    ans = min(ans, rec(index + 1) + a);

    return T[index] = ans;
}

void solve()
{
    printf("%d\n", rec(0));
}

int main()
{
    read_input();
    solve();

    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")

#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 5010;
const double EPS = 1e-9;
const int BASE = 257;

mt19937 rnd;

ull h[MX];
ull pw[MX];

ull sub(int l, int r) {
    return h[r + 1] - h[l] * pw[r - l + 1];
}

map<ull, int> pos;
int dp[MX];

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, a, b;
    cin >> n >> a >> b;
    str s;
    cin >> s;
    pw[0] = 1;
    fi(1, n + 1) {
        pw[i] = pw[i - 1] * BASE;
        h[i] = h[i - 1] * BASE + s[i - 1];
    }
    fi(0, n) {
        fj(i, n) {
            ull hs = sub(i, j);
            if (pos.find(hs) == pos.end())
                pos[hs] = i;
        }
    }
    dp[0] = a;
    fi(1, n) {
        dp[i] = dp[i - 1] + a;
        fj(0, i) {
            if (dp[j] + b < dp[i]) {
                ull hs = sub(j + 1, i);
                int k = pos[hs];
                if (k + (i - j - 1) <= j)
                    dp[i] = dp[j] + b;
            }
        }
    }

    cout << dp[n - 1];
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
*/

#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 5010;
const double EPS = 1e-9;
const int BASE = 257;

mt19937 rnd;

ull h[MX];
ull pw[MX];

ull sub(int l, int r) {
    return h[r + 1] - h[l] * pw[r - l + 1];
}

map<ull, int> pos;
int dp[MX];

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, a, b;
    cin >> n >> a >> b;
    str s;
    cin >> s;
    pw[0] = 1;
    fi(1, n + 1) {
        pw[i] = pw[i - 1] * BASE;
        h[i] = h[i - 1] * BASE + s[i - 1];
    }
    fi(0, n) {
        fj(i, n) {
            ull hs = sub(i, j);
            if (pos.find(hs) == pos.end())
                pos[hs] = i;
        }
    }
    dp[0] = a;
    fi(1, n) {
        dp[i] = dp[i - 1] + a;
        fj(0, i) {
            if (dp[j] + b < dp[i]) {
                ull hs = sub(j + 1, i);
                int k = pos[hs];
                if (k + (i - j - 1) <= j)
                    dp[i] = dp[j] + b;
            }
        }
    }

    cout << dp[n - 1];
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>

/*
#pragma GCC optimize("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
*/

#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 5010;
const double EPS = 1e-9;
const int BASE = 257;

mt19937 rnd;

ull h[MX];
ull pw[MX];
int h2[MX];
int pw2[MX];
ull sub(int l, int r) {
    return h[r + 1] - h[l] * pw[r - l + 1];
}

int sub2(int l, int r) {
    int res = h2[r + 1] - 1ll * h2[l] * pw2[r - l + 1] % MOD;
    if (res < 0)
        res += MOD;
    return res;
}

int dp[MX];

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, a, b;
    cin >> n >> a >> b;
    str s;
    cin >> s;
    pw[0] = pw2[0] = 1;
    fi(1, n + 1) {
        pw[i] = pw[i - 1] * BASE;
        pw2[i] = pw2[i - 1] * BASE % MOD;
        h[i] = h[i - 1] * BASE + s[i - 1];
        h2[i] = (1ll * h2[i - 1] * BASE + s[i - 1]) % MOD;
    }
    dp[0] = a;
    fi(1, n) {
        dp[i] = dp[i - 1] + a;
        int l = -1;
        int r = i;
        while (r - l > 1) {
            int m = (r + l) >> 1;
            ull need = sub(m + 1, i);
            int need2 = sub2(m + 1, i);
            fj(0, 2 * m - i +2) {
                if (sub(j, j + i - m -1) == need && sub2(j, j + i - m  - 1) == need2) {
                    r = m;
                    break;
                }
            }
            if (r != m)
                l = m;
        }
        if (r < i)
            dp[i] = min(dp[i], dp[r] + b);
    }

    cout << dp[n - 1];
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>

#pragma GCC optimize("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")

#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 5010;
const double EPS = 1e-9;
const int BASE = 257;

mt19937 rnd;

ull h[MX];
ull pw[MX];

ull sub(int l, int r) {
    return h[r + 1] - h[l] * pw[r - l + 1];
}

map<ull, int> pos;
int dp[MX];

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, a, b;
    cin >> n >> a >> b;
    str s;
    cin >> s;
    pw[0] = 1;
    fi(1, n + 1) {
        pw[i] = pw[i - 1] * BASE;
        h[i] = h[i - 1] * BASE + s[i - 1];
    }
    fi(0, n) {
        fj(i, n) {
            ull hs = sub(i, j);
            if (pos.find(hs) == pos.end())
                pos[hs] = i;
        }
    }
    dp[0] = a;
    fi(1, n) {
        dp[i] = dp[i - 1] + a;
        fj(0, i) {
            if (dp[j] + b < dp[i]) {
                ull hs = sub(j + 1, i);
                int k = pos[hs];
                if (k + (i - j - 1) <= j)
                    dp[i] = dp[j] + b;
            }
        }
    }

    cout << dp[n - 1];
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>

/*
#pragma GCC optimize("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
*/

#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 5010;
const double EPS = 1e-9;
const int BASE = 257;

mt19937 rnd;

int dp[MX];
int z[MX][MX];
int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, a, b;
    cin >> n >> a >> b;
    str s;
    cin >> s;
    fi(0, n) {
        int r = i - 1;
        int l = i;
        fj(i + 1, n) {
            z[i][j] = max(0, min(r - j + 1, z[i][j - l + i]));
            while (j + z[i][j] < n && s[i + z[i][j]] == s[j + z[i][j]])
                ++z[i][j];
            if (j + z[i][j] - 1 > r) {
                r = j + z[i][j] -1;
                l = j;
            }
        }
    }
    dp[0] = a;
    fi(1, n) {
        dp[i] = dp[i - 1] + a;
        int l = -1;
        int r = i;
        while (r - l > 1) {
            int m = (r + l) >> 1;
            fj(0, 2 * m - i +2) {
                if (z[j][m + 1] >= i - m) {
                    r = m;
                    break;
                }
            }
            if (r != m)
                l = m;
        }
        if (r < i)
            dp[i] = min(dp[i], dp[r] + b);
    }

    cout << dp[n - 1];
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>

/*
#pragma GCC optimize("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
*/

#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 5010;
const double EPS = 1e-9;
const int BASE = 257;

mt19937 rnd;

ull h[MX];
ull pw[MX];
int h2[MX];
int pw2[MX];
ull sub(int l, int r) {
    return h[r + 1] - h[l] * pw[r - l + 1];
}

int sub2(int l, int r) {
    int res = h2[r + 1] - 1ll * h2[l] * pw2[r - l + 1] % MOD;
    if (res < 0)
        res += MOD;
    return res;
}

int dp[MX];

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, a, b;
    cin >> n >> a >> b;
    str s;
    cin >> s;
    pw[0] = pw2[0] = 1;
    fi(1, n + 1) {
        pw[i] = pw[i - 1] * BASE % MOD;
        pw2[i] = pw2[i - 1] * BASE;
        h[i] = h[i - 1] * BASE + s[i - 1];
        h2[i] = (1ll * h2[i - 1] * BASE + s[i - 1]) % MOD;
    }
    dp[0] = a;
    fi(1, n) {
        dp[i] = dp[i - 1] + a;
        int l = -1;
        int r = i;
        while (r - l > 1) {
            int m = (r + l) >> 1;
            ull need = sub(m + 1, i);
            int need2 = sub2(m + 1, i);
            fj(0, 2 * m - i +2) {
                if (sub(j, j + i - m -1) == need && sub2(j, j + i - m  - 1) == need2) {
                    r = m;
                    break;
                }
            }
            if (r != m)
                l = m;
        }
        if (r < i)
            dp[i] = min(dp[i], dp[r] + b);
    }

    cout << dp[n - 1];
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>

/*
#pragma GCC optimize("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
*/

#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 5010;
const double EPS = 1e-9;
const int BASE = 257;

mt19937 rnd;

ull h[MX];
ull pw[MX];

ull sub(int l, int r) {
    return h[r + 1] - h[l] * pw[r - l + 1];
}

map<ull, int> first;
int pos[MX][MX];
int dp[MX];

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, a, b;
    cin >> n >> a >> b;
    str s;
    cin >> s;
    pw[0] = 1;
    fi(1, n + 1) {
        pw[i] = pw[i - 1] * BASE;
        h[i] = h[i - 1] * BASE + s[i - 1];
    }
    fi(0, n) {
        fj(i, n) {
            ull hs = sub(i, j);
            auto it = first.find(hs);
            if (it == first.end()) {
                first[hs] = i;
                pos[i][j] = i;
            } else {
                pos[i][j] = it->second;
            }
        }
    }
    dp[0] = a;
    fi(1, n) {
        dp[i] = dp[i - 1] + a;
        fj(0, i) {
            if (dp[j] + b < dp[i]) {
                int k = pos[j + 1][i];
                if (k + (i - j - 1) <= j) {
                    dp[i] = dp[j] + b;
                    break;
                }
            }
        }
    }

    cout << dp[n - 1];
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>

/*
#pragma GCC optimize("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
*/

#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 5010;
const double EPS = 1e-9;
const int BASE = 257;

mt19937 rnd;

ull h[MX];
ull pw[MX];
int h2[MX];
int pw2[MX];
ull sub(int l, int r) {
    return h[r + 1] - h[l] * pw[r - l + 1];
}

int sub2(int l, int r) {
    int res = h2[r + 1] - 1ll * h2[l] * pw2[r - l + 1] % MOD;
    if (res < 0)
        res += MOD;
    return res;
}

int dp[MX];

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, a, b;
    cin >> n >> a >> b;
    str s;
    cin >> s;
    pw[0] = pw2[0] = 1;
    fi(1, n + 1) {
        pw[i] = pw[i - 1] * BASE;
        pw2[i] = pw2[i - 1] * BASE;
        h[i] = h[i - 1] * BASE + s[i - 1];
        h2[i] = (1ll * h2[i - 1] * BASE + s[i - 1]) % MOD;
    }
    dp[0] = a;
    fi(1, n) {
        dp[i] = dp[i - 1] + a;
        int l = -1;
        int r = i;
        while (r - l > 1) {
            int m = (r + l) >> 1;
            ull need = sub(m + 1, i);
            int need2 = sub2(m + 1, i);
            fj(0, 2 * m - i +2) {
                if (sub(j, j + i - m -1) == need && sub2(j, j + i - m  - 1) == need2) {
                    r = m;
                    break;
                }
            }
            if (r != m)
                l = m;
        }
        if (r < i)
            dp[i] = min(dp[i], dp[r] + b);
    }

    cout << dp[n - 1];
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>

/*
#pragma GCC optimize("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
*/

#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 5010;
const double EPS = 1e-9;
const int BASE = 257;

mt19937 rnd;

ull h[MX];
ull pw[MX];

ull sub(int l, int r) {
    return h[r + 1] - h[l] * pw[r - l + 1];
}

map<ull, int> first;
int pos[MX][MX];
int dp[MX];

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, a, b;
    cin >> n >> a >> b;
    str s;
    cin >> s;
    pw[0] = 1;
    fi(1, n + 1) {
        pw[i] = pw[i - 1] * BASE;
        h[i] = h[i - 1] * BASE + s[i - 1];
    }
    fi(0, n) {
        fj(i, n) {
            ull hs = sub(i, j);
            auto it = first.find(hs);
            if (it == first.end()) {
                first[hs] = i;
                pos[i][j] = i;
            } else {
                pos[i][j] = it->second;
            }
        }
    }
    dp[0] = a;
    fi(1, n) {
        dp[i] = dp[i - 1] + a;
        int l = -1;
        int r = i;
        while (r - l > 1) {
            int m = (r + l) >> 1;
            int k = pos[m + 1][i];
            if (k + (i - m - 1) <= m)
                r = m;
            else
                l = m;
        }
        if (r < i)
            dp[i] = min(dp[i], dp[r] + b);
    }

    cout << dp[n - 1];
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>

/*
#pragma GCC optimize("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
*/

#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 5010;
const double EPS = 1e-9;
const int BASE = 257;

mt19937 rnd;

ull h[MX];
ull pw[MX];

ull sub(int l, int r) {
    return h[r + 1] - h[l] * pw[r - l + 1];
}

map<ull, int> first;
int pos[MX][MX];
int dp[MX];

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, a, b;
    cin >> n >> a >> b;
    str s;
    cin >> s;
    pw[0] = 1;
    fi(1, n + 1) {
        pw[i] = pw[i - 1] * BASE;
        h[i] = h[i - 1] * BASE + s[i - 1];
    }
    dp[0] = a;
    fi(1, n) {
        dp[i] = dp[i - 1] + a;
        int l = -1;
        int r = i;
        while (r - l > 1) {
            int m = (r + l) >> 1;
            ull need = sub(m + 1, i);
            fj(0, 2 * m - i +2) {
                if (sub(j, j + i - m -1) == need) {
                    r = m;
                    break;
                }
            }
            if (r != m)
                l = m;
        }
        if (r < i)
            dp[i] = min(dp[i], dp[r] + b);
    }

    cout << dp[n - 1];
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>

/*
#pragma GCC optimize("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
*/

#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 5010;
const double EPS = 1e-9;
const int BASE = 257;

mt19937 rnd;

ull h[MX];
ull pw[MX];

ull sub(int l, int r) {
    return h[r + 1] - h[l] * pw[r - l + 1];
}

map<ull, int> first;
int pos[MX][MX];
int dp[MX];

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, a, b;
    cin >> n >> a >> b;
    str s;
    cin >> s;
    pw[0] = 1;
    fi(1, n + 1) {
        pw[i] = pw[i - 1] * BASE;
        h[i] = h[i - 1] * BASE + s[i - 1];
    }
    fi(0, n) {
        fj(i, n) {
            ull hs = sub(i, j);
            auto it = first.find(hs);
            if (it == first.end()) {
                first[hs] = i;
                pos[i][j] = i;
            } else {
                pos[i][j] = it->second;
            }
        }
    }
    dp[0] = a;
    fi(1, n) {
        dp[i] = dp[i - 1] + a;
        fj(0, i) {
            if (dp[j] + b < dp[i]) {
                int k = pos[j + 1][i];
                if (k + (i - j - 1) <= j)
                    dp[i] = dp[j] + b;
            }
        }
    }

    cout << dp[n - 1];
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>

#pragma GCC optimize("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")

#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 5010;
const double EPS = 1e-9;
const int BASE = 257;

mt19937 rnd;

ull h[MX];
ull pw[MX];

ull sub(int l, int r) {
    return h[r + 1] - h[l] * pw[r - l + 1];
}

map<ull, int> first;
int pos[MX][MX];
int dp[MX];

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, a, b;
    cin >> n >> a >> b;
    str s;
    cin >> s;
    pw[0] = 1;
    fi(1, n + 1) {
        pw[i] = pw[i - 1] * BASE;
        h[i] = h[i - 1] * BASE + s[i - 1];
    }
    fi(0, n) {
        fj(i, n) {
            ull hs = sub(i, j);
            auto it = first.find(hs);
            if (it == first.end()) {
                first[hs] = i;
                pos[i][j] = i;
            } else {
                pos[i][j] = it->second;
            }
        }
    }
    dp[0] = a;
    fi(1, n) {
        dp[i] = dp[i - 1] + a;
        fj(0, i) {
            if (dp[j] + b < dp[i]) {
                int k = pos[j + 1][i];
                if (k + (i - j - 1) <= j)
                    dp[i] = dp[j] + b;
            }
        }
    }

    cout << dp[n - 1];
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>

/*
#pragma GCC optimize("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
*/

#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 5010;
const double EPS = 1e-9;
const int BASE = 257;

mt19937 rnd;

ull h[MX];
ull pw[MX];
int h2[MX];
int pw2[MX];
ull sub(int l, int r) {
    return h[r + 1] - h[l] * pw[r - l + 1];
}

int sub2(int l, int r) {
    int res = h2[r + 1] - 1ll * h2[l] * pw2[r - l + 1] % MOD;
    if (res < 0)
        res += MOD;
    return res;
}

int dp[MX];

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, a, b;
    cin >> n >> a >> b;
    str s;
    cin >> s;
    pw[0] = pw2[0] = 1;
    fi(1, n + 1) {
        pw[i] = pw[i - 1] * BASE;
        pw2[i] = 1ll * pw2[i - 1] * BASE % MOD;
        h[i] = h[i - 1] * BASE + s[i - 1];
        h2[i] = (1ll * h2[i - 1] * BASE + s[i - 1]) % MOD;
    }
    dp[0] = a;
    fi(1, n) {
        dp[i] = dp[i - 1] + a;
        int l = -1;
        int r = i;
        while (r - l > 1) {
            int m = (r + l) >> 1;
            ull need = sub(m + 1, i);
            int need2 = sub2(m + 1, i);
            fj(0, 2 * m - i +2) {
                if (sub(j, j + i - m -1) == need && sub2(j, j + i - m  - 1) == need2) {
                    r = m;
                    break;
                }
            }
            if (r != m)
                l = m;
        }
        if (r < i)
            dp[i] = min(dp[i], dp[r] + b);
    }

    cout << dp[n - 1];
}


#include <iostream>
#include <list>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

const  int LIM = 5100;

int a, b, n;

int dp[LIM];

int main()
{
    cin >> n >> a >> b;
    string str;
    cin >> str;

    int res = 0;
    dp[0] = a;
    for( int dpi = 1; dpi < n; ++dpi )
    {
        dp[dpi] = dp[dpi - 1] + a;

        string sub =  str.substr( 0, dpi + 1);
        reverse(sub.begin(), sub.end());
        vector< int > z(dpi+1, 0);
        int lh = 0;

        for( int i = 1, l = 0, r = 0; i < dpi + 1; ++i )
        {
            //cerr << z[i] << " ";
            if( i <= r )
                z[i] = min( r - i + 1, z[i - l]);

            while (i + z[i] < n && sub[z[i]] == sub[i + z[i]])
                ++z[i];

            if (i + z[i] - 1 > r)
                l = i, r = i + z[i] - 1;

            if( z[i] > i )
                lh = max( lh, i );
            else
                lh = max( lh, z[i] );
        }

        if( lh != 0 )
            dp[dpi] = min( dp[dpi], dp[dpi - lh] + b );

       // cerr << dpi << ": " <<  lh << "   " << dp[dpi] << "\n";
    }

    cout << dp[n - 1];

    return 0;
};


#include <iostream>
#include <list>
#include <string>
#include <algorithm>

using namespace std;

const  int LIM = 5100;

int a, b, n;

int dp[LIM];

int main()
{
    cin >> n >> a >> b;
    string str;
    cin >> str;

    int res = 0;
    dp[0] = a;
    for( int dpi = 1; dpi < n; ++dpi )
    {
        dp[dpi] = dp[dpi - 1] + a;

        string sub =  str.substr( 0, dpi + 1);
        reverse(sub.begin(), sub.end());
        vector< int > z(dpi+1, 0);
        int lh = 0;

        for( int i = 1, l = 0, r = 0; i < dpi + 1; ++i )
        {
            //cerr << z[i] << " ";
            if( i <= r )
                z[i] = min( r - i + 1, z[i - l]);

            while (i + z[i] < n && sub[z[i]] == sub[i + z[i]])
                ++z[i];

            if (i + z[i] - 1 > r)
                l = i, r = i + z[i] - 1;

            if( z[i] > i )
                lh = max( lh, i );
            else
                lh = max( lh, z[i] );
        }

        if( lh != 0 )
            dp[dpi] = min( dp[dpi], dp[dpi - lh] + b );

       // cerr << dpi << ": " <<  lh << "   " << dp[dpi] << "\n";
    }

    cout << dp[n - 1];

    return 0;
};


#include <iostream>
#include <list>
#include <string>

using namespace std;

const  int LIM = 5100;

int a, b, n;

int dp[LIM];

int main()
{
    cin >> n >> a >> b;
    string str;
    cin >> str;

    int res = 0;
    dp[0] = a;
    for( int dpi = 1; dpi < n; ++dpi )
    {
        dp[dpi] = dp[dpi - 1] + a;
        for( int j = dpi - 1; j >= 0; --j )
        {
            string sub = str.substr( 0, j + 1 );
            if( sub.find(str.substr(j + 1, dpi - j )) != string::npos  )
            {
                dp[dpi] = min( dp[dpi], dp[j] + b );
            }
        }
    }

    cout << dp[n - 1];

    return 0;
};


#include <iostream>
#include <list>

using namespace std;

const  int LIM = 5100;

int a, b, n;

int main()
{
    cin >> n >> a >> b;
    string str;
    cin >> str;

    int res = 0;
    for( int i = 0; i < n; ++i )
    {
        int len = 0;
        list< int > l;
        //l.push_back(0);

        for( int j = 0; j < i && len < n - i; ++j )
        {
            list< int >::iterator it = l.begin();

            while( it != l.end() )
            {
                if( *it + i >= n )
                {
                    len = *it + 1;
                    break;
                }
                if( str[j] == str[i + *it] )
                {
                    //cout << j << " <> " << i + *it << "\n";
                    (*it) += 1;
                    ++it;

                    len = max( len, *it + 1 );
                }
                else
                {
                    list< int >::iterator emp = it;
                    ++emp;
                    len = max( len, *it  );
                    l.erase(it);
                    it = emp;
                }

            }
            //cout << "\n\n";
            if( str[j] == str[i] )
            {
                l.push_back(1);
                len = max( len, 1 );
            }
        }
        //cout << "\n";

        if( len == 0 )
            res += a;
        else if( len * a > b )
        {
            res += b;
            i += len - 1;
        }
        else
        {
            res += a * len;
            i += len - 1;
        }

        //cout << i << ": " << res << " :" << len  << "\n";
    }

    cout << res;

    return 0;
};


#include <iostream>
#include <list>

using namespace std;

const  int LIM = 5100;

int a, b, n;

int main()
{
    cin >> n >> a >> b;
    string str;
    cin >> str;

    int res = 0;
    for( int i = 0; i < n; ++i )
    {
        int len = 0;
        list< int > l;
        //l.push_back(0);

        for( int j = 0; j < i && len < n - i; ++j )
        {
            list< int >::iterator it = l.begin();

            while( it != l.end() )
            {
                if( *it + i >= n )
                {
                    len = *it + 1;
                    break;
                }
                if( str[j] == str[i + *it] )
                {
                    //cout << j << " <> " << i + *it << "\n";
                    (*it) += 1;
                    ++it;

                    len = max( len, *it + 1 );
                }
                else
                {
                    list< int >::iterator emp = it;
                    ++emp;
                    len = max( len, *it  );
                    l.erase(it);
                    it = emp;
                }

            }
            //cout << "\n\n";
            if( str[j] == str[i] )
            {
                l.push_back(1);
                len = max( len, 1 );
            }
        }
        //cout << "\n";

        if( len == 0 )
            res += a;
        else if( len * a > b )
        {
            res += b;
            i += len - 1;
        }
        else
            res += a;

        //cout << i << ": " << res << " :" << len  << "\n";
    }

    cout << res;

    return 0;
};


#include <iostream>
#include <list>

using namespace std;

const  int LIM = 5100;

int a, b, n;

int main()
{
    cin >> n >> a >> b;
    string str;
    cin >> str;

    int res = 0;
    for( int i = 0; i < n; ++i )
    {
        int len = 0;
        list< int > l;
        l.push_back(0);

        for( int j = 0; j < i && len < n - i; ++j )
        {
            list< int >::iterator it = l.begin();

            while( it != l.end() )
            {
                if( *it + i >= n )
                {
                    len = *it + 1;
                    break;
                }
                if( str[j] == str[i + *it] )
                {
                    (*it) += 1;
                    ++it;

                    len = max( len, *it + 1 );
                }
                else
                {
                    list< int >::iterator emp = it;
                    ++emp;
                    len = max( len, *it  );
                    l.erase(it);
                    it = emp;
                }

            }
            if( str[j] == str[i] )
                l.push_back(1);
        }

        if( len == 0 )
            res += a;
        else if( len * a > b )
        {
            res += b;
            i += len - 1;
        }
        else
            res += a;

        //cout << i << ": " << res << " :" << len  << "\n";
    }

    cout << res;

    return 0;
};


#include <iostream>
#include <cstring>
using namespace std;
const int maxn=10005;
int Next[maxn][30],fa[maxn],len[maxn],root=1,tot=1,last=1;
int n,a,b;
char s[maxn];
void extend(int c){
	int p=last,np=++tot;
	len[np]=len[p]+1;
	last=np;
	for (;p&&!Next[p][c];p=fa[p]) Next[p][c]=np;
	if (!p){
		fa[np]=root;
	}else{
		int q=Next[p][c];
		if (len[q]==len[p]+1)
			fa[np]=q;
		else{
			int nq=++tot;
			len[nq]=len[p]+1;
			fa[nq]=fa[q];
			fa[np]=fa[q]=nq;
			memcpy(Next[nq],Next[q],sizeof nq);
			for(;p&&Next[p][c]==q;p=fa[p]) Next[p][c]=nq;
		}
	}
}
int yuan[maxn],dp[maxn];
int pao(int u){
	int cur=root;
	int len=0;
	for (int i=u;i<=n;i++){
		if (Next[cur][s[i]-'a'])
			cur=Next[cur][s[i]-'a'],len++;
		else
			return len;
	}
}
int main(){
	scanf("%d%d%d",&n,&a,&b);
	scanf("%s",s);
	for (int i=0;i<n;i++){
		yuan[i]=pao(i);
		extend(s[i]-'a');
	}
	memset(dp,1,sizeof(dp));
	dp[0]=0;
	for (int i=0;i<n;i++){
		for (int j=i+1;j<=i+yuan[i+1];j++){
			dp[j]=min(dp[j],dp[i]+b);
		}
		dp[i+1]=min(dp[i+1],dp[i]+a);
	}
	cout << dp[n];
}


#include <iostream>
#include <cstring>
using namespace std;
const int maxn=10005;
int Next[maxn][30],fa[maxn],len[maxn],root=1,tot=1,last=1;
int n,a,b;
char s[maxn];
void extend(int c){
	int p=last,np=++tot;
	len[np]=len[p]+1;
	last=np;
	for (;p&&!Next[p][c];p=fa[p]) Next[p][c]=np;
	if (!p){
		fa[np]=root;
	}else{
		int q=Next[p][c];
		if (len[q]==len[p]+1)
			fa[np]=q;
		else{
			int nq=++tot;
			len[nq]=len[p]+1;
			fa[nq]=fa[q];
			fa[np]=fa[q]=nq;
			memcpy(Next[nq],Next[q],sizeof Next[nq]);
			for(;p&&Next[p][c]==q;p=fa[p]) Next[p][c]=nq;
		}
	}
}
int yuan[maxn],dp[maxn];
int pao(int u){
	int cur=root;
	int len=0;
	for (int i=u;i<n;i++){
		if (Next[cur][s[i]-'a'])
			cur=Next[cur][s[i]-'a'],len++;
		else
			return len;
	}
	return len;
}
int main(){
	scanf("%d%d%d",&n,&a,&b);
	scanf("%s",s);
	for (int i=0;i<n;i++){
		yuan[i]=pao(i);
		extend(s[i]-'a');
	}
	memset(dp,1,sizeof(dp));
	dp[0]=0;
	/*for (int i=0;i<n;i++){
		cout << yuan[i] << ' ';
	}*/
	cout << endl;
	for (int i=0;i<n;i++){
		for (int j=i+1;j<=i+yuan[i+1];j++){
			dp[j]=min(dp[j],dp[i]+b);
		}
		dp[i+1]=min(dp[i+1],dp[i]+a);
	}
	cout << dp[n];
}/*
30 4114 2743
eeaeaebdacdbabccbddcaddcddceea
010221001011111111111321321321
69944
010221001011111121111322321321
67201*/


#include <iostream>
#include <cstring>
using namespace std;
int n;
int a,b,k,j;
typedef long long ll;
const int mod=1e9+7;
const int aa=354;
const int bb=673;
const int maxn=5005;
char s[maxn];
int dp[maxn];
int yuan[maxn];
struct node{
	ll a,b;
	bool operator ==(const node c)const {
		return (a==c.a)&&(b==c.b);
	}
};
node hh[maxn],u,v;
bool flag;
int l,r,mid,len;
ll a1[maxn],b1[maxn];
node get(node a,node b,int len){
	node c={(a.a*a1[len])%mod,(a.b*b1[len])%mod};
	return {((b.a-c.a)%mod+mod)%mod,((b.b-c.b)%mod+mod)%mod};
}
int main(){
	scanf("%d%d%d",&n,&a,&b);
	scanf("%s",s+1);
	a1[0]=1;b1[0]=1;
	for (int i=1;i<=n;i++){
		a1[i]=a1[i-1]*aa%mod;
		b1[i]=b1[i-1]*bb%mod;
		hh[i].a=(hh[i-1].a*aa+s[i]-'a')%mod;
		hh[i].b=(hh[i-1].b*bb+s[i]-'a')%mod;
	}
	for (int i=1;i<=n;i++){
		j=1;
		l=i,r=n;
		while (l<=r){
			mid=l+r>>1,len=mid-i+1;
			flag=false;
			u=get(hh[i-1],hh[i+len-1],len);
			for (int k=1;k<=i-1;k++){
				if (k+len-1>=i) break;
				v=get(hh[k-1],hh[k+len-1],len);
				if (u==v){
					flag=true;
					break;
				}
			}
			if (flag)
				l=mid+1;
			else
				r=mid-1;
		}
		if (r>=i)
			yuan[i]=r;
		else
			yuan[i]=-1;
	}/*
	for (int i=1;i<=n;i++){
		cout << yuan[i]-i+1 << ' ';
	}
	cout << endl;*/
	memset(dp,1,sizeof(dp));
	dp[0]=0;
	for (int i=0;i<n;i++){
		for (int j=i+1;j<=yuan[i+1];j++){
			dp[j]=min(dp[j],dp[i]+b);
		}
		dp[i+1]=min(dp[i+1],dp[i]+a);
	}
	cout << dp[n];
}