#include <bits/stdc++.h>
using namespace std;
inline int min(int d, int e) { return d > e ? e : d; }
inline int max(int d, int e) { return d > e ? d : e; }
class Costflow {
  struct Edge {
    int u, v, f, cap, cost, n;
  };
  int h[2000], d[2000], pre[2000];
  int minf, u, v, p, cnt;
  bool vis[2000];
  Edge e[60000];
  queue<int> Q;

 public:
  int S, T, flow, cost;
  Costflow() {
    memset(h, 255, sizeof(h));
    cnt = 0;
    flow = 0;
    cost = 0;
  }
  void init() {
    memset(h, 255, sizeof(h));
    cnt = 0;
    flow = 0;
    cost = 0;
  }

 private:
  void add(int u, int v, int cap, int cost) {
    e[cnt].u = u;
    e[cnt].v = v;
    e[cnt].f = 0;
    e[cnt].cap = cap;
    e[cnt].cost = cost;
    e[cnt].n = h[u];
    h[u] = cnt;
    cnt++;
  }
  bool spfa() {
    memset(vis, 0, sizeof(vis));
    memset(pre, 255, sizeof(pre));
    memset(d, 127, sizeof(d));
    Q.push(S);
    d[S] = 0;
    vis[S] = 1;
    while (!Q.empty()) {
      u = Q.front();
      Q.pop();
      vis[u] = 0;
      for (p = h[u]; p >= 0; p = e[p].n)
        if (e[p].cap > e[p].f && d[e[p].v] > d[u] + e[p].cost) {
          v = e[p].v;
          d[v] = d[u] + e[p].cost;
          pre[v] = p;
          if (!vis[v]) Q.push(v), vis[v] = 1;
        }
    }
    if (d[T] > 1888888888)
      return 0;
    else
      return 1;
  }

 public:
  void addedge(int u, int v, int cap, int cost) {
    add(u, v, cap, cost);
    add(v, u, 0, -cost);
  }
  void costflow() {
    while (spfa()) {
      minf = 1888888888;
      for (p = pre[T]; p >= 0; p = pre[e[p].u])
        minf = min(minf, e[p].cap - e[p].f);
      for (p = pre[T]; p >= 0; p = pre[e[p].u])
        e[p].f += minf, e[p ^ 1].f -= minf;
      flow += minf;
      cost += minf * d[T];
    }
  }
};
Costflow z;
int a[105][2] = {0}, b[105] = {0}, o[105] = {0}, l = 0, n, m;
inline int N(int i) { return m + 3 + i; }
inline int M(int i) { return 3 + i; }
int main() {
  int i, j, ss = 0, sss = 0;
  char c[10];
  string s;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%s%d", c, &a[i][0]);
    s = c;
    if (s == "ATK") {
      a[i][1] = 1;
    }
  }
  for (i = 0; i < m; i++) {
    scanf("%d", &b[i]);
    ss += b[i];
  }
  for (i = 3; i <= m + 2; i++) z.addedge(1, i, 1, 0);
  for (i = 0; i < m; i++)
    for (j = 0; j < n; j++) {
      if (b[i] >= a[j][0] && a[j][1] == 1 || a[j][1] == 0 && b[i] > a[j][0]) {
        if (a[j][1] == 1)
          z.addedge(M(i), N(j), 1, a[j][0]);
        else
          z.addedge(M(i), N(j), 1, b[i]);
      }
    }
  for (i = m + 3; i <= m + n + 2; i++) z.addedge(i, 2, 1, 0);
  z.S = 1;
  z.T = 2;
  z.costflow();
  if (z.flow < n)
    ss = 0;
  else
    ss -= z.cost;
  for (i = 0; i < n; i++)
    if (a[i][1] == 1) o[l++] = a[i][0];
  sort(b, b + m);
  sort(o, o + l);
  reverse(b, b + m);
  for (i = 0; i < min(m, l); i++)
    if (b[i] > o[i])
      sss += b[i] - o[i];
    else
      break;
  printf("%d\n", max(sss, ss));
  return 0;
}
