#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long w[103], w1[100003], ans;
long long w2[100003], w3[100003];
long long dp[100003];
vector<long long> v1, v2;
map<long long, long long> M, M1;
long long a, b, c, n, m, q, k, x;
long long poww(long long x, long long y) {
  if (x == 0) return 0;
  if (x == 1) return 1;
  if (y == 0) return 1;
  if (y == 1) return x;
  long long d = poww(x, y / 2);
  return d * d;
}
bool r(long long x, long long y) { return x > y; }
int main() {
  scanf("%lld%lld", &n, &m);
  for (int i = 1; i <= n; i++) {
    char ss[10];
    scanf("%s%lld", &ss, &a);
    string s = ss;
    if (s == "ATK")
      v1.push_back(a);
    else
      v2.push_back(a);
  }
  for (int i = 1; i <= m; i++) scanf("%lld", &w[i]);
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  sort(w, w + m + 1);
  b = m + 1;
  for (int i = 0; i < v1.size(); i++) {
    for (int j = b - 1; j >= 1; j--) {
      if (w[j] >= v1[i]) {
        ans += w[j] - v1[i];
        b = j;
        break;
      }
    }
  }
  c = 0;
  b = 0;
  bool l = 0;
  if (v2.size() == 0) l = 1;
  for (int i = 0; i < v2.size(); i++) {
    for (int j = b + 1; j <= m; j++) {
      if (w[j] > v2[i]) {
        w[j] = -1;
        b = j;
        if (i == v2.size() - 1) l = 1;
        break;
      }
    }
  }
  if (!l) return cout << ans, 0;
  l = 0;
  sort(w, w + m + 1);
  b = 0;
  if (v1.size() == 0) l = 1;
  for (int i = 0; i < v1.size(); i++) {
    for (int j = b + 1; j <= m; j++) {
      if (w[j] >= v1[i]) {
        c += w[j] - v1[i];
        w[j] = -1;
        b = j;
        if (i == v1.size() - 1) l = 1;
        break;
      }
    }
  }
  if (!l) return cout << ans, 0;
  for (int i = 1; i <= m; i++) {
    if (w[i] > 0) c += w[i];
  }
  cout << max(ans, c);
}
