#include <bits/stdc++.h>
using namespace std;
int A[100010], B[100010], f[1000];
bool cmp(int aa, int bb) { return aa > bb; }
bool vis[1000];
int n, m, an = 0, dn = 0;
int solve(int def) {
  int i = 1, top = 1;
  if (def == 1) top = an;
  int kill = 0, sum = 0;
  int ret = 0;
  for (; top <= an; top++) {
    i = top;
    sum = 0;
    for (int j = m; j >= 1; j--)
      if (!vis[j]) {
        if (def) sum += f[j];
        if (i > 0 && f[j] >= A[i]) {
          sum += f[j] - A[i];
          if (def) sum -= f[j];
          kill++;
        }
        i--;
      }
    if (!def) ret = max(ret, sum);
  }
  if (def && kill == an) return sum;
  if (def) return -100000;
  if (!def) return ret;
}
int main() {
  cin >> n >> m;
  string s;
  int t;
  for (int i = 1; i <= n; i++) {
    cin >> s >> t;
    if (s[0] == 'D')
      B[++dn] = t;
    else
      A[++an] = t;
  }
  for (int i = 1; i <= m; i++) cin >> f[i];
  int ans = 0;
  sort(A + 1, A + 1 + an);
  sort(B + 1, B + 1 + dn);
  sort(f + 1, f + 1 + m);
  int temp = 0, j = 1, cnt = 0;
  for (int i = 1; i <= dn; i++) {
    while (j <= m && f[j] <= B[i]) j++;
    if (j <= m && f[j] > B[i]) {
      cnt++;
      vis[j] = true;
      j++;
    }
  }
  if (cnt == dn) ans += solve(1);
  memset(vis, false, sizeof(vis));
  ans = max(ans, solve(0));
  cout << max(ans, 0) << endl;
}
