#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
int n, m;
vector<int> atk, def;
vector<int> my;
int solve1() {
  int gans = 0;
  int num = 0;
  int ans = 0;
  int curi = 0;
  for (int i = 0; i < int(atk.size()); i++) {
    while (curi < m && my[curi] < atk[i]) curi++;
    if (curi == m) break;
    num++;
    ans += my[m - num];
    ans -= atk[i];
    gans = max(ans, gans);
    curi++;
  }
  return gans;
}
const int MAXN = 100 + 10;
bool is[MAXN + 1];
int solve2() {
  int ans = 0;
  int curi = 0;
  for (int i = 0; i < int(def.size()); i++) {
    while (curi < m && my[curi] <= def[i]) curi++;
    if (curi == m) return 0;
    is[curi] = true;
    curi++;
  }
  curi = 0;
  for (int i = 0; i < int(atk.size()); i++) {
    while (curi < m && (is[curi] || my[curi] < atk[i])) curi++;
    if (curi == m) return 0;
    ans -= atk[i];
    curi++;
  }
  for (int i = 0; i < m; i++)
    if (!is[i]) ans += my[i];
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string s;
    int sc;
    cin >> s >> sc;
    if (s == "ATK")
      atk.push_back(sc);
    else
      def.push_back(sc);
  }
  for (int i = 0; i < m; i++) {
    int sc;
    cin >> sc;
    my.push_back(sc);
  }
  sort(atk.begin(), atk.end());
  sort(def.begin(), def.end());
  sort(my.begin(), my.end());
  int ans1 = solve1(), ans2 = solve2();
  cout << max(ans1, ans2) << endl;
  return 0;
}
