#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<long long> v;
vector<long long> atk;
vector<long long> def;
long long dp[107][107][107][2];
int inf = -100000000;
long long f(int vidx, int atkidx, int defidx, int all) {
  if (vidx == v.size()) {
    if (all == 0) return 0;
    if (all == 1) {
      if (atkidx == atk.size() and defidx == def.size())
        return 0;
      else
        return inf;
    }
  }
  long long &ret = dp[vidx][atkidx][defidx][all];
  if (ret != -1) return ret;
  ret = inf;
  ret = max(ret, f(vidx + 1, atkidx, defidx, all));
  ret = max(ret, v[vidx] + f(vidx + 1, atkidx, defidx, 1));
  if (atkidx < atk.size() and v[vidx] >= atk[atkidx]) {
    ret =
        max(ret, v[vidx] - atk[atkidx] + f(vidx + 1, atkidx + 1, defidx, all));
  }
  if (defidx < def.size() and v[vidx] > def[defidx]) {
    ret = max(ret, f(vidx + 1, atkidx, defidx + 1, all));
  }
  return ret;
}
int main() {
  memset(dp, 0xff, sizeof(dp));
  cin >> n >> m;
  for (long long i = int(0); i <= int(n - 1); i++) {
    string tp;
    cin >> tp;
    long long str;
    cin >> str;
    if (tp == "ATK") {
      atk.push_back(str);
    } else {
      def.push_back(str);
    }
  }
  for (long long j = int(0); j <= int(m - 1); j++) {
    long long str;
    cin >> str;
    v.push_back(str);
  }
  sort(atk.begin(), atk.end());
  sort(def.begin(), def.end());
  sort(v.begin(), v.end());
  for (auto it = (def).begin(); it != (def).end(); it++)
    if (true)
      cerr << "*it"
           << ": " << *it << endl;
  ;
  cout << f(0, 0, 0, 0) << endl;
  return 0;
}
