#include <bits/stdc++.h>
using namespace std;
void quicksort(int a[], int left, int right);
int a[100], x = 0, b[100], y = 0, ar[100];
int main() {
  int n, m, sum = 0, max = 0, sum1 = 0;
  scanf("%d%d", &m, &n);
  for (int i = 0; i < m; i++) {
    string s;
    int temp;
    cin >> s >> temp;
    if (s == "ATK") {
      a[x] = temp;
      x++;
    } else {
      b[y] = temp;
      y++;
    }
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &ar[i]);
    sum += ar[i];
  }
  for (int i = 0; i < x; i++) sum -= a[i];
  for (int i = 0; i < y; i++) sum -= b[i];
  quicksort(ar, 0, n - 1);
  quicksort(a, 0, x - 1);
  quicksort(b, 0, y - 1);
  int p = 0, q = n - 1;
  while (ar[q] >= a[p] && p < x && q >= 0) {
    max += ar[q] - a[p];
    q--;
    p++;
  }
  int z = 0, check = 0;
  if (sum > max) {
    for (int i = 0; i < y; i++) {
      while (b[i] >= ar[z]) {
        z++;
        if (z == n) {
          sum = 0;
          check = 1;
          break;
        }
      }
      if (check == 0) {
        sum = sum + b[i] - ar[z];
        ar[z] = 0;
      }
    }
  }
  quicksort(ar, 0, n - 1);
  q = n - 1;
  for (int i = x - 1; i >= 0; i--) {
    if (ar[q] < a[i]) {
      sum = 0;
      check = 1;
    }
    q--;
  }
  if (sum > max) max = sum;
  printf("%d\n", max);
}
void quicksort(int a[], int left, int right) {
  int i = left, j = right;
  int pivot = a[(left + right) / 2];
  int temp = 0;
  while (i <= j) {
    while (a[i] < pivot) i++;
    while (a[j] > pivot) j--;
    if (i <= j) {
      temp = a[i];
      a[i] = a[j];
      a[j] = temp;
      i++;
      j--;
    }
  }
  if (left < j) quicksort(a, left, j);
  if (right > i) quicksort(a, i, right);
}
