#include <bits/stdc++.h>
using namespace std;
int vis[110];
vector<int> Atk, Def, Ciel;
int main() {
  char op[10];
  int n, m, i, j, k, ans, tmp;
  while (scanf("%d%d", &n, &m) != EOF) {
    Atk.clear();
    Def.clear();
    Ciel.clear();
    for (i = 1; i <= n; i++) {
      scanf("%s%d", op, &k);
      if (op[0] == 'A')
        Atk.push_back(k);
      else
        Def.push_back(k);
    }
    for (i = 1; i <= m; i++) {
      scanf("%d", &k);
      Ciel.push_back(k);
    }
    sort(Atk.begin(), Atk.end());
    sort(Def.begin(), Def.end());
    sort(Ciel.begin(), Ciel.end());
    for (i = 1, ans = 0; i <= m; i++) {
      if (Atk.size() < i) break;
      for (j = tmp = 0; j < i; j++) {
        if (Ciel[m - i + j] < Atk[j]) break;
        tmp += Ciel[m - i + j] - Atk[j];
      }
      if (j >= i && tmp > ans) ans = tmp;
    }
    memset(vis, 0, sizeof(vis));
    for (i = k = 0; i < Ciel.size(); i++) {
      if (k < Def.size() && Ciel[i] > Def[k]) k++, vis[i] = 1;
    }
    if (k == Def.size()) {
      for (i = k = tmp = 0; i < Ciel.size(); i++) {
        if (vis[i]) continue;
        tmp += Ciel[i];
        if (k < Atk.size() && Ciel[i] >= Atk[k]) {
          tmp -= Atk[k];
          k++;
        }
      }
      if (k == Atk.size() && tmp > ans) ans = tmp;
    }
    printf("%d\n", ans);
  }
  return 0;
}
