#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> edge;
map<string, int> id;
int now = 0;
int main() {
  int n, cost, tcost, card, ccost;
  scanf("%d %d %d %d %d", &n, &cost, &tcost, &card, &ccost);
  string last;
  for (int i = 0; i < n; i++) {
    string a, b;
    cin >> a >> b;
    if (id[a] == 0) id[a] = ++now;
    if (id[b] == 0) id[b] = ++now;
    int node1 = id[a];
    int node2 = id[b];
    if (node1 > node2) swap(node1, node2);
    if (i && last == a)
      edge[{node1, node2}] += tcost;
    else
      edge[{node1, node2}] += cost;
    last = b;
  }
  int total = 0;
  vector<int> v;
  for (auto it = edge.begin(); it != edge.end(); it++) {
    v.push_back(it->second);
  }
  sort(v.begin(), v.end(), greater<int>());
  for (int i = 0; i < v.size(); i++) {
    if (card && v[i] > ccost) v[i] = ccost, card--;
    total += v[i];
  }
  printf("%d\n", total);
  return 0;
}
