#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, m;
vector<int> a;
vector<int> b;
int c[N];
int used[N];
int beatAll() {
  memset(used, 0, sizeof(used));
  for (int i = 0; i < b.size(); i++) {
    int j;
    for (j = 0; j < m; j++) {
      if (!used[j] && c[j] > b[i]) {
        used[j] = 1;
        break;
      }
    }
    if (j == m) return 0;
  }
  int res = 0;
  for (int i = 0; i < a.size(); i++) {
    int j;
    for (j = 0; j < m; j++) {
      if (!used[j] && c[j] >= a[i]) {
        used[j] = 1;
        res += c[j] - a[i];
        break;
      }
    }
    if (j == m) return 0;
  }
  for (int i = 0; i < m; i++)
    if (!used[i]) {
      res += c[i];
    }
  return res;
}
int beatSome() {
  int res = 0;
  memset(used, 0, sizeof(used));
  for (int i = a.size() - 1; i >= 0; i--) {
    bool flag = 1;
    memset(used, 0, sizeof(used));
    int cur = 0;
    for (int j = i; j >= 0; j--) {
      int k;
      for (k = m - 1; k >= 0; k--) {
        if (!used[k] && c[k] >= a[j]) {
          cur += c[k] - a[j];
          used[k] = 1;
          break;
        }
      }
      if (k < 0) {
        flag = 0;
        break;
      }
    }
    if (flag && cur > res) {
      res = cur;
    }
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    char buf[10];
    scanf("%s", buf);
    int cur;
    scanf("%d", &cur);
    if (strcmp(buf, "ATK") == 0) {
      a.push_back(cur);
    } else {
      b.push_back(cur);
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &c[i]);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c, c + m);
  int res = beatAll();
  res = max(res, beatSome());
  cout << res << endl;
}
