#include <bits/stdc++.h>
using namespace std;
template <typename T>
void to_max(T &_x, const T &_y) {
  _x = max(_x, _y);
}
vector<int> aset;
vector<int> dset;
multiset<int> myset;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    char op[105];
    scanf("%s", (op));
    int v;
    scanf("%d", &v);
    if (op[0] == 'A')
      aset.push_back(v);
    else
      dset.push_back(v);
  }
  for (int i = 0; i < m; i++) {
    int v;
    scanf("%d", &v);
    myset.insert(v);
  }
  sort((aset).begin(), (aset).end());
  sort((dset).begin(), (dset).end());
  int ans = 0;
  multiset<int> tmp = myset;
  bool can = true;
  for (__typeof((dset).begin()) it = (dset).begin(); it != (dset).end(); ++it) {
    multiset<int>::iterator jt = tmp.upper_bound(*it);
    if (jt == tmp.end()) {
      can = false;
      break;
    }
    tmp.erase(jt);
  }
  int curr = 0;
  if (can) {
    for (__typeof((aset).begin()) it = (aset).begin(); it != (aset).end();
         ++it) {
      multiset<int>::iterator jt = tmp.lower_bound(*it);
      if (jt == tmp.end()) {
        can = false;
        break;
      }
      curr += *jt - *it;
      tmp.erase(jt);
    }
  }
  if (can) {
    for (__typeof((tmp).begin()) it = (tmp).begin(); it != (tmp).end(); ++it) {
      curr += *it;
    }
    ans = curr;
  }
  for (int i = 0; i < min(((int)(aset).size()), ((int)(myset).size())); i++) {
    curr = 0;
    multiset<int>::iterator it = myset.end();
    bool flag = true;
    for (int j = i; j >= 0; j--) {
      --it;
      if (aset[j] > *it) {
        flag = false;
        break;
      }
      curr += *it - aset[j];
    }
    if (flag) to_max(ans, curr);
  }
  cout << ans << endl;
  return 0;
}
