#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int i = -1;
  const int N = 101;
  int cl[N], ja[N], jan = 0, jd[N], jdn = 0;
  char buf[18];
  while (++i < n) {
    scanf("%s%d", buf, ja + jan);
    if (buf[0] == 'A')
      ++jan;
    else
      jd[jdn++] = ja[jan];
  }
  i = -1;
  int cl1[N];
  while (++i < m) {
    scanf("%d", cl + i);
  }
  sort(ja, ja + jan);
  sort(jd, jd + jdn);
  sort(cl, cl + m);
  i = -1;
  while (++i < m) cl1[i] = cl[i];
  i = -1;
  int j = 0;
  while (++i < jdn) {
    while (j < m && cl[j] <= jd[i]) ++j;
    if (j == m)
      break;
    else {
      cl[j] = -1;
    }
  }
  int td = 0;
  if (i == jdn) {
    j = 0;
    i = -1;
    while (++i < jan) {
      while (j < m && cl[j] < ja[i]) ++j;
      if (j == m)
        break;
      else {
        td += cl[j] - ja[i];
        cl[j] = -1;
      }
    }
    if (i == jan) {
      i = -1;
      while (++i < m) {
        if (cl[i] > 0) td += cl[i];
      }
    }
  }
  i = -1;
  j = m - 1;
  int td2 = 0;
  while (++i < jan) {
    if (j > -1 && cl1[j] > ja[i]) {
      td2 += cl1[j] - ja[i];
      --j;
    } else {
      break;
    }
  }
  printf("%d\n", td > td2 ? td : td2);
  return 0;
}
