#include <bits/stdc++.h>
using namespace std;
long long N, A, B, K, F;
int id_cnt = 0;
map<string, int> id;
map<pair<int, int>, long long> val;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> A >> B >> K >> F;
  int last = -1;
  for (int x = 0, ThxDem = N; x < ThxDem; ++x) {
    string s[2];
    for (int y = 0, ThxDem = 2; y < ThxDem; ++y) {
      cin >> s[y];
      if (!id.count(s[y])) id[s[y]] = id_cnt++;
    }
    int u = id[s[0]], v = id[s[1]];
    val[{min(u, v), max(u, v)}] += last == id[s[0]] ? B : A;
    last = id[s[1]];
  }
  priority_queue<pair<long long, pair<int, int> > > pq;
  for (auto p : val) pq.push({p.second, p.first});
  long long ans = 0;
  while (!pq.empty()) {
    if (K) {
      if (pq.top().first > F) {
        ans += F;
        pq.pop();
        K--;
      } else {
        ans += pq.top().first;
        pq.pop();
      }
    } else {
      ans += pq.top().first;
      pq.pop();
    }
  }
  cout << ans << "\n";
  return 0;
}
