#include <bits/stdc++.h>
using namespace std;
int Me, He, M[100], H[100], DefPos;
bool att[100];
int barrima() {
  sort(M, M + Me);
  bool taken[100];
  int totDestroyed = 0, totDamage = 0;
  memset(taken, 0, sizeof taken);
  for (int i = 0; i < He; i++) {
    if (att[i]) continue;
    for (int j = 0; j < Me; j++) {
      if (taken[j]) continue;
      if (M[j] <= H[i]) continue;
      taken[j] = 1;
      totDestroyed++;
      break;
    }
  }
  if (totDestroyed != DefPos) return 0;
  for (int i = 0; i < He; i++) {
    if (!att[i]) continue;
    for (int j = 0; j < Me; j++) {
      if (taken[j]) continue;
      if (M[j] < H[i]) continue;
      taken[j] = 1;
      totDestroyed++;
      totDamage += (M[j] - H[i]);
      break;
    }
  }
  if (totDestroyed != He) return 0;
  for (int i = 0; i < Me; i++)
    if (!taken[i]) totDamage += M[i];
  return totDamage;
}
int KillHim() {
  vector<int> v;
  for (int i = 0; i < He; i++)
    if (att[i]) v.push_back(H[i]);
  sort(v.begin(), v.end());
  sort(M, M + Me);
  int Maxi = 0;
  for (int K = 1; K <= v.size(); K++) {
    int totKilled = 0, i = Me - 1, totDamage = 0;
    while (totKilled++ != K) {
      if (M[i] < v[totKilled - 1]) break;
      totDamage += M[i] - v[totKilled - 1];
      i--;
    }
    Maxi = max(Maxi, totDamage);
  }
  return Maxi;
}
int main() {
  cin >> He >> Me;
  for (int i = 0; i < He; i++) {
    string s;
    cin >> s >> H[i];
    if (s == "ATK")
      att[i] = 1;
    else
      DefPos++;
  }
  for (int i = 0; i < Me; i++) cin >> M[i];
  cout << max(barrima(), KillHim()) << endl;
  return 0;
}
