#include <bits/stdc++.h>
using namespace std;
map<string, int> Con;
int Obtener(string s) {
  if (Con[s] == 0) Con[s] = Con.size();
  return Con[s];
}
int Cost[601][601], n, a, b, k, f, pv;
int main() {
  cin >> n >> a >> b >> k >> f;
  for (int i = 0; i < n; i++) {
    string u, v;
    cin >> u >> v;
    int iu = Obtener(u), iv = Obtener(v);
    if (iu == pv)
      Cost[iu][iv] += b, Cost[iv][iu] += b;
    else
      Cost[iu][iv] += a, Cost[iv][iu] += a;
    pv = iv;
  }
  int L = Con.size(), CT = 0;
  vector<int> Costv;
  for (int i = 1; i <= L; i++)
    for (int j = i + 1; j <= L; j++)
      if (Cost[i][j] > 0) Costv.push_back(Cost[i][j]), CT += Cost[i][j];
  k = min(k, (int)Costv.size());
  sort(Costv.rbegin(), Costv.rend());
  int Lv = Costv.size();
  for (int i = 0; i < k && Costv[i] >= f; i++) CT -= Costv[i] - f;
  cout << CT << endl;
}
