#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void smn(T &a, const T &b) {
  if (b < a) a = b;
}
template <class T>
inline void smx(T &a, const T &b) {
  if (b > a) a = b;
}
template <class T>
inline T _rev(const T &a) {
  T _ = a;
  reverse(_.begin(), _.end());
  return _;
}
const double eps = 1e-8;
const long double leps = 1e-14;
int n, m;
vector<int> f, s;
vector<int> all;
int res = 0;
bool mark[10000];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int a;
    string s;
    cin >> s >> a;
    if (s == "ATK")
      f.push_back(a);
    else
      ::s.push_back(a);
  }
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    all.push_back(a);
  }
  sort(all.begin(), all.end());
  sort(f.begin(), f.end());
  for (int i = 0; i < m && i < f.size(); i++) {
    int now = 0;
    for (int j = i, k = m - 1; j >= 0; j--, k--)
      if (all[k] < f[j])
        goto hell;
      else
        now += all[k] - f[j];
    smx(res, now);
  hell:;
  }
  if (m >= n) {
    for (int i = 0; i < m - n; i++) f.push_back(0);
    sort(f.begin(), f.end());
    sort(s.begin(), s.end());
    int now = 0;
    int p = all.size() - 1;
    for (int i = s.size() - 1; i >= 0; i--) {
      bool find = false;
      for (int j = 0; j < all.size(); j++)
        if (mark[j] == 0 && all[j] > s[i]) {
          mark[j] = 1;
          find = true;
          break;
        }
      if (!find) goto h2;
    }
    for (int i = f.size() - 1; i >= 0; i--) {
      while (p >= 0 && mark[p] == 1) p--;
      if (p < 0 || all[p] < f[i]) goto h2;
      now += all[p] - f[i];
      mark[p] = 1;
    }
    smx(res, now);
  h2:;
  }
  cout << res << '\n';
  return 0;
}
