#include <bits/stdc++.h>
using namespace std;
const int MAXN = 103;
int a[MAXN];
int d[MAXN];
int c[MAXN];
int n, m;
int na, nd, nc;
int solve0(int s) {
  int ret = 0;
  for (int i = s, j = 0; i < nc && j < na; i++) {
    if (c[i] >= a[j]) ret += c[i] - a[j++];
  }
  return ret;
}
int solve1() {
  static bool u[MAXN];
  for (int i = 0; i < nd; i++) {
    bool f = false;
    for (int j = 0; j < nc; j++)
      if (!u[j] && c[j] > d[i]) {
        f = true;
        u[j] = true;
        break;
      }
    if (!f) return 0;
  }
  int ret = 0;
  int j = 0;
  for (int i = 0; i < nc; i++) {
    if (u[i]) continue;
    if (j == na) {
      ret += c[i];
      u[i] = true;
    } else if (c[i] >= a[j]) {
      ret += c[i] - a[j++];
      u[i] = true;
    }
  }
  if (j == na)
    for (int i = 0; i < nc; i++)
      if (!u[i]) ret += c[i];
  return ret;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    char t[10];
    int x;
    scanf("%s%d", t, &x);
    if (t[0] == 'D')
      d[nd++] = x;
    else
      a[na++] = x;
  }
  nc = m;
  for (int i = 0; i < m; i++) scanf("%d", c + i);
  sort(a, a + na);
  sort(c, c + nc);
  sort(d, d + nd);
  int ans = solve1();
  for (int i = 0; i < nc; i++) ans = max(ans, solve0(i));
  printf("%d\n", ans);
  return 0;
}
