#include <bits/stdc++.h>
using namespace std;
map<string, int> m;
int p = 0, c[605][605], d[400005];
int get(string s) {
  if (!m[s]) m[s] = ++p;
  return m[s];
}
int main() {
  int n, a, b, i, j, k, f, x, y, z = -1;
  string s1, s2;
  memset(c, 0, sizeof c);
  cin >> n >> a >> b >> k >> f;
  for (i = 0; i < n; ++i) {
    cin >> s1 >> s2;
    x = get(s1);
    y = get(s2);
    if (z == x)
      c[x][y] += b;
    else
      c[x][y] += a;
    z = y;
  }
  n = z = 0;
  for (i = 1; i <= p; ++i) {
    d[++n] = c[i][i];
    z += d[n];
    for (j = 1; j < i; ++j) {
      d[++n] = c[i][j] + c[j][i];
      z += d[n];
    }
  }
  sort(d + 1, d + 1 + n);
  for (i = max(1, n - k + 1); i <= n; ++i)
    if (d[i] > f) z -= d[i] - f;
  cout << z;
}
