#include <bits/stdc++.h>
using namespace std;
bool mx(int a) {
  if (a < 0) {
    return (0);
  }
  return (a);
}
vector<int> a, oa, od;
int n, m;
bool nused[100];
int main() {
  cin >> n >> m;
  string h;
  int p;
  for (int x = 0; x < n; x++) {
    cin >> h >> p;
    if (h == "ATK") {
      oa.push_back(p);
    } else {
      od.push_back(p);
    }
  }
  for (int x = 0; x < m; x++) {
    nused[x] = true;
    cin >> p;
    a.push_back(p);
  }
  sort(a.begin(), a.end());
  sort(oa.begin(), oa.end());
  sort(od.begin(), od.end());
  bool kall = true;
  int dmg1 = 0, dmg2 = 0;
  if (kall && m > n) {
    for (int x = od.size() - 1; x > -1; x--) {
      int z = 0;
      while (z < a.size() && (a[z] <= od[x] || !nused[z])) {
        z++;
      }
      if (z < a.size()) {
        nused[z] = false;
      } else {
        kall = false;
      }
    }
    for (int x = oa.size() - 1; x > -1; x--) {
      int z = 0;
      while (z < a.size() && (a[z] < oa[x] || !nused[z])) {
        z++;
      }
      if (z < a.size()) {
        nused[z] = false;
        dmg1 += a[z] - oa[x];
      } else {
        kall = false;
      }
    }
  }
  if (kall && m > n) {
    for (int x = 0; x < a.size(); x++) {
      if (nused[x]) {
        dmg1 += a[x];
      }
    }
  }
  for (int x = 0; x < min(a.size(), oa.size()); x++) {
    if (a[a.size() - x - 1] >= oa[x]) {
      dmg2 += a[a.size() - x - 1] - oa[x];
    }
  }
  if (kall) {
    cout << max(dmg1, dmg2) << endl;
  } else {
    cout << dmg2 << endl;
  }
}
