#include <bits/stdc++.h>
using namespace std;
int N, A, B, K, F;
map<string, int> mp;
int id(const string &s) {
  if (mp.count(s)) return mp[s];
  int sz = int(mp.size());
  return mp[s] = sz;
}
map<pair<int, int>, int> edge;
int main() {
  ios::sync_with_stdio(false);
  cin >> N >> A >> B >> K >> F;
  int pre = -1;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    string su, sv;
    cin >> su >> sv;
    int u = id(su), v = id(sv);
    ans += pre == u ? B : A;
    edge[minmax(u, v)] += pre == u ? B : A;
    pre = v;
  }
  vector<int> diff;
  for (auto it = edge.begin(); it != edge.end(); ++it) {
    if (it->second > F) {
      diff.emplace_back(it->second - F);
    }
  }
  sort(diff.begin(), diff.end(), greater<int>());
  for (int i = 0; i < min(K, int(diff.size())); ++i) {
    ans -= diff[i];
  }
  cout << ans << endl;
  return 0;
}
