#include <bits/stdc++.h>
using namespace std;
int a[111];
pair<int, int> b[111];
bool used[111];
int n, m;
int solve1() {
  for (int i = 1; i <= n; i++)
    if (b[i].second == -1) {
      bool fl = false;
      for (int j = 1; j <= m; j++)
        if (!used[j] && a[j] > b[i].first) {
          used[j] = true;
          fl = true;
          break;
        }
      if (!fl) return 0;
    }
  int cur_ans = 0;
  for (int i = 1; i <= n; i++)
    if (b[i].second == 1) {
      bool fl = false;
      for (int j = 1; j <= m; j++)
        if (!used[j] && a[j] >= b[i].first) {
          cur_ans += a[j] - b[i].first;
          used[j] = true;
          fl = true;
          break;
        }
      if (!fl) return 0;
    }
  for (int i = 1; i <= m; i++)
    if (!used[i]) cur_ans += a[i];
  return cur_ans;
}
int main() {
  int asum = 0, bsum = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    string s;
    int x;
    cin >> s >> x;
    if (s == "ATK")
      b[i] = make_pair(x, 1);
    else
      b[i] = make_pair(x, -1);
    bsum += x;
  }
  for (int i = 1; i <= m; i++) {
    cin >> a[i];
    asum += a[i];
  }
  sort(b + 1, b + n + 1);
  sort(a + 1, a + m + 1);
  int ans1 = 0, ans2 = 0;
  ans1 = solve1();
  int kol = 0;
  reverse(a + 1, a + m + 1);
  for (int i = 1; i <= n && kol < m; i++)
    if (b[i].second == 1) {
      kol++;
      if (a[kol] >= b[i].first) ans2 += a[kol] - b[i].first;
    }
  cout << max(ans1, ans2);
  cin >> n;
  return 0;
}
