#include <bits/stdc++.h>
using namespace std;
int kill_defence(vector<int> jdef, vector<int> jatk, vector<int> catk) {
  vector<int> kill;
  sort(catk.begin(), catk.end());
  sort(jdef.begin(), jdef.end());
  kill.assign(catk.size(), 0);
  int killer = -1;
  for (int dit = 0; dit < jdef.size(); ++dit) {
    int val = jdef[dit];
    ++killer;
    if (killer > catk.size()) {
      return -1;
    }
    while (catk[killer] <= val) {
      ++killer;
      if (killer > catk.size()) {
        return -1;
      }
    }
    kill[killer] = 1;
  }
  vector<int> restatk;
  for (int i = 0; i < catk.size(); ++i) {
    if (kill[i] == 0) {
      restatk.push_back(catk[i]);
    }
  }
  sort(restatk.rbegin(), restatk.rend());
  if (restatk.size() < jatk.size()) {
    return -1;
  }
  sort(jatk.rbegin(), jatk.rend());
  for (int it = 0; it < jatk.size(); ++it) {
    if (restatk[it] < jatk[it]) {
      return -1;
    }
  }
  int ans = 0;
  for (int jj = 0; jj < restatk.size(); ++jj) {
    ans += restatk[jj];
  }
  for (int ii = 0; ii < jatk.size(); ++ii) {
    ans -= jatk[ii];
  }
  return ans;
}
int no_defence(vector<int> jatk, vector<int> catk) {
  sort(jatk.begin(), jatk.end());
  sort(catk.rbegin(), catk.rend());
  int profit = 0;
  for (int jirost = 0; jirost < jatk.size(); ++jirost) {
    int jdub = jirost;
    int temprofit = 0;
    int cind = 0;
    while (jdub >= 0 && cind < catk.size()) {
      if (jatk[jdub] <= catk[cind]) {
        temprofit += (catk[cind] - jatk[jdub]);
      } else {
        break;
      }
      --jdub;
      ++cind;
    }
    if (temprofit > profit) {
      profit = temprofit;
    }
  }
  return profit;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  int jcd, ccd;
  cin >> jcd >> ccd;
  vector<int> jatk;
  vector<int> jdef;
  for (int i = 0; i < jcd; ++i) {
    string st;
    cin >> st;
    int v;
    cin >> v;
    if (st == "ATK") {
      jatk.push_back(v);
    } else {
      jdef.push_back(v);
    }
  }
  vector<int> ccv;
  for (int i = 0; i < ccd; ++i) {
    int jjl;
    cin >> jjl;
    ccv.push_back(jjl);
  }
  int ans = max(no_defence(jatk, ccv), kill_defence(jdef, jatk, ccv));
  cout << ans << endl;
  return 0;
}
