#include <bits/stdc++.h>
using namespace std;
int dirx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int diry[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int n, m;
string s;
const int inf = 1e9;
vector<int> a, d, cs;
long long dp[101][101][101][2];
long long rec(int c, int ja, int jd, bool kill) {
  if (c == m) {
    if (kill && (ja != a.size() || jd != d.size())) return -inf;
    return 0;
  }
  if (ja == a.size() && jd == d.size()) return rec(c + 1, ja, jd, kill) + cs[c];
  long long &res = dp[c][ja][jd][kill];
  if (~res) return res;
  res = rec(c + 1, ja, jd, kill);
  if (kill) res += cs[c];
  if (ja != a.size() && a[ja] <= cs[c]) {
    res = max(res, rec(c + 1, ja + 1, jd, kill) + cs[c] - a[ja]);
  }
  if (jd < d.size() && d[jd] < cs[c]) {
    res = max(res, rec(c + 1, ja, jd + 1, kill));
  }
  return res;
}
int main() {
  memset(dp, -1, sizeof dp);
  ;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    int val;
    cin >> s >> val;
    if (s == "ATK")
      a.push_back(val);
    else
      d.push_back(val);
  }
  for (long long i = 0; i < m; i++) {
    int val;
    cin >> val;
    cs.push_back(val);
  }
  sort(a.begin(), a.end());
  sort(d.begin(), d.end());
  sort(cs.begin(), cs.end());
  cout << max(rec(0, 0, 0, 0), rec(0, 0, 0, 1));
}
