#include <bits/stdc++.h>
using namespace std;
int a[100];
int b[100];
int c[100];
bool is[100];
int main() {
  int n, m;
  int z = 0, x = 0;
  char q[5];
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", q);
    switch (q[0]) {
      case 'A':
        scanf("%d", &b[z++]);
        break;
      case 'D':
        scanf("%d", &c[x++]);
    }
  }
  for (int j = 0; j < m; j++) scanf("%d", &a[j]);
  sort(a, a + m);
  sort(b, b + z);
  sort(c, c + x);
  int max1 = 0, max2 = 0;
  int j = 0;
  fill(is, is + m, true);
  for (int i = m - 1; i >= 0; i--) {
    if (a[i] >= b[j] && j < z) {
      max1 += a[i] - b[j];
      j++;
    } else {
      break;
    }
  }
  if (a[m - 1] > c[x - 1] && m > n) {
    int i = 0;
    int k;
    for (k = 0; k < x && i < m; k++) {
      while (a[i] <= c[k] && i < m - 1) i++;
      is[i] = false;
      i++;
    }
    if (k == x) {
      i = 0;
      for (int k = 0; k < z && i < m; k++) {
        while (!is[i] || a[i] < b[k] && i < m - 1) {
          i++;
        }
        max2 += a[i] - b[k];
        is[i] = false;
        i++;
      }
      if (i < m)
        for (i = 0; i < m; i++)
          if (is[i]) max2 += a[i];
    }
  }
  int sum;
  sum = max(max1, max2);
  printf("%d\n", sum);
}
