#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 + 5;
int A[MAXN], AA[MAXN], A_size, AA_size;
int B[MAXN], BB[MAXN], B_size, BB_size;
int n, m;
bool mark[MAXN];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string s;
    int a;
    cin >> s >> a;
    if (s == "ATK")
      A[A_size++] = a;
    else
      AA[AA_size++] = a;
  }
  for (int i = 0; i < m; i++) cin >> B[B_size++];
  sort(B, B + m);
  sort(A, A + A_size);
  sort(AA, AA + AA_size);
  int ans = 0;
  int p = 0, q = 0;
  while (p < B_size and q < AA_size) {
    if (B[p] <= AA[q])
      p++;
    else {
      mark[p] = true;
      p++;
      q++;
    }
  }
  if (q == AA_size) {
    p = 0;
    q = 0;
    while (p < B_size and q < A_size) {
      if (mark[p] or B[p] < A[q]) {
        p++;
        continue;
      }
      mark[p] = true;
      ans += B[p] - A[q];
      p++;
      q++;
    }
    if (q == A_size)
      for (int i = 0; i < B_size; i++)
        if (!mark[i]) ans += B[i];
  }
  int ff = 0;
  p = m - 1, q = 0;
  while (p >= 0 and q < A_size) {
    if (B[p] < A[q]) break;
    ff += B[p] - A[q];
    p--;
    q++;
  }
  cout << max(ans, ff) << endl;
  return 0;
}
