#include <bits/stdc++.h>
using namespace std;
vector<int> ciel;
vector<int> atk;
vector<int> def;
static int DP[101][101][101][2] = {-1};
int minf = numeric_limits<int>::min();
int solve(int cielidx, int atkidx, int defidx, int nocard) {
  if (cielidx == ciel.size()) {
    if ((!nocard) || ((atkidx == atk.size()) && (defidx == def.size())))
      return 0;
    return minf;
  }
  int &ret = DP[cielidx][atkidx][defidx][nocard];
  if (-1 != ret) return ret;
  ret = minf;
  int cielatk = ciel[cielidx];
  ret = max(ret, solve(cielidx + 1, atkidx, defidx, nocard));
  ret = max(ret, solve(cielidx + 1, atkidx, defidx, 1) + cielatk);
  if (atkidx < atk.size() && (cielatk >= atk[atkidx])) {
    ret = max(ret, solve(cielidx + 1, atkidx + 1, defidx, nocard) + cielatk -
                       atk[atkidx]);
  }
  if (defidx < def.size() && (cielatk > def[defidx])) {
    ret = max(ret, solve(cielidx + 1, atkidx, defidx + 1, nocard));
  }
  return ret;
}
int main(void) {
  int n, m, val;
  string s;
  cin >> n >> m;
  while (n--) {
    cin >> s;
    cin >> val;
    if ("ATK" == s) {
      atk.push_back(val);
    } else
      def.push_back(val);
  }
  while (m--) {
    cin >> val;
    ciel.push_back(val);
  }
  memset(DP, -1, sizeof(DP));
  sort(ciel.begin(), ciel.end());
  sort(atk.begin(), atk.end());
  sort(def.begin(), def.end());
  cout << solve(0, 0, 0, 0) << endl;
  return 0;
}
