#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
vector<int> v[2];
int t[maxn], a[maxn], b[maxn], c[maxn];
bool cmp(int a, int b) { return a > b; }
int get(int t1, int t2, int t3) {
  multiset<int> s;
  for (int i = 1; i <= t1; i++) s.insert(t[i]);
  for (int i = t3 - 1; i >= 0; i--) {
    if (v[1][i] >= *(s.rbegin())) return 0;
    s.erase(s.upper_bound(v[1][i]));
  }
  int sum = 0;
  for (int i = t2 - 1; i >= 0; i--) {
    int k = *s.rbegin();
    if (v[0][i] > k) return 0;
    sum += k - v[0][i];
    s.erase((++s.rbegin()).base());
  }
  for (int i : s) sum += i;
  return sum;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    string t1;
    int t2;
    cin >> t1 >> t2;
    if (t1 == "ATK")
      v[0].push_back(t2);
    else
      v[1].push_back(t2);
  }
  if (v[0].size()) sort(v[0].begin(), v[0].end());
  if (v[1].size()) sort(v[1].begin(), v[1].end());
  int s1 = v[0].size(), s2 = v[1].size();
  for (int i = 1; i <= m; i++) cin >> t[i];
  sort(t + 1, t + 1 + m, cmp);
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    if (i <= s1)
      ans = max(ans, get(i, i, 0));
    else
      ans = max(ans, get(i, s1, min(s2, i - s1)));
  }
  cout << ans << endl;
}
