#include <bits/stdc++.h>
using namespace std;
int luat_tot(vector<int>& attack, vector<int>& defense, multiset<int> carti);
int luare(vector<int>& attack, multiset<int> carti);
int main() {
  int n, m, c;
  char s[10];
  vector<int> attack, defense;
  multiset<int> carti;
  cin >> n >> m;
  for (int i(0); i < n; i++) {
    cin >> s >> c;
    if (s[0] == 'A')
      attack.push_back(c);
    else
      defense.push_back(c);
  }
  while (m--) {
    cin >> c;
    carti.insert(c);
  }
  sort(attack.rbegin(), attack.rend());
  int r(luat_tot(attack, defense, carti));
  vector<int> attack_part;
  while (!attack.empty()) {
    attack_part.push_back(attack.back());
    attack.pop_back();
    sort(attack_part.rbegin(), attack_part.rend());
    r = max(r, luare(attack_part, carti));
  }
  cout << r;
  return 0;
}
int luare(vector<int>& attack, multiset<int> carti) {
  int r(0);
  for (auto i : attack) {
    if (carti.empty()) return 0;
    if (*carti.rbegin() < i) return 0;
    r += *carti.rbegin() - i;
    carti.erase(carti.find(*carti.rbegin()));
  }
  return r;
}
int luat_tot(vector<int>& attack, vector<int>& defense, multiset<int> carti) {
  int r(0);
  for (auto i : defense) {
    if (carti.empty()) return 0;
    if (carti.upper_bound(i) == carti.end()) return 0;
    carti.erase(carti.upper_bound(i));
  }
  for (auto i : attack) {
    if (carti.empty() || *carti.rbegin() < i) return 0;
    r += *carti.rbegin() - i;
    carti.erase(carti.find(*carti.rbegin()));
  }
  for (auto i : carti) r += i;
  return r;
}
