#include <bits/stdc++.h>
using namespace std;
vector<int> vec[1002];
int cost[1002][1002];
int dis[1002];
bool cmp(int a, int b) { return a > b; }
int main() {
  int a, b, k, f, n, u1, v1, u2, v2;
  scanf("%d %d %d %d %d", &n, &a, &b, &k, &f);
  map<string, int> mymap;
  int i, j;
  int cnt = 1;
  string s1, s2;
  memset(cost, 0, sizeof(cost));
  u1 = -1;
  v1 = -1;
  for (i = 0; i < n; i++) {
    cin >> s1 >> s2;
    if (mymap[s1] == 0) {
      mymap[s1] = cnt;
      cnt++;
    }
    if (mymap[s2] == 0) {
      mymap[s2] = cnt;
      cnt++;
    }
    cost[mymap[s1]][mymap[s2]] += a;
    u2 = mymap[s1];
    v2 = mymap[s2];
    if (u2 == v1) {
      cost[mymap[s1]][mymap[s2]] = cost[mymap[s1]][mymap[s2]] - a;
      cost[mymap[s1]][mymap[s2]] += b;
    }
    u1 = u2;
    v1 = v2;
  }
  int num = 0;
  for (i = 1; i < cnt; i++) {
    for (j = i; j < cnt; j++) {
      if (cost[i][j] + cost[j][i] > 0) {
        dis[num++] = cost[i][j] + cost[j][i];
      }
    }
  }
  sort(dis, dis + num, cmp);
  int sum = 0;
  for (i = 0; i < num; i++) {
    if (dis[i] > f && k > 0) {
      sum = sum + f;
      k--;
    } else {
      sum = sum + dis[i];
    }
  }
  printf("%d\n", sum);
}
