#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500;
int INF = ~0U >> 1;
int CINF = ~0U >> 1;
struct minCostMaxFlow {
  struct Edge {
    int x, y;
    int cap;
    int cost;
  };
  int N, prev[MAXN];
  int dist[MAXN];
  vector<Edge> E;
  vector<int> g[MAXN];
  minCostMaxFlow(int _N) : N(_N) {}
  void addEdge(int x, int y, int cap, int cost) {
    Edge e1 = {x, y, cap, cost}, e2 = {y, x, 0, -cost};
    g[x].push_back(E.size());
    E.push_back(e1);
    g[y].push_back(E.size());
    E.push_back(e2);
  }
  pair<int, int> mcmf(int s, int t, bool maxflow) {
    int flow = 0;
    int cost = 0;
    while (true) {
      const int MAX_FLOW = ~0U >> 1;
      vector<int> dist(N, INF);
      vector<int> am(N, 0);
      vector<int> prev(N);
      vector<bool> inQ(N, false);
      queue<int> que;
      dist[s] = 0;
      am[s] = MAX_FLOW;
      que.push(s);
      inQ[s] = true;
      while (!que.empty()) {
        int u = que.front();
        int c = dist[u];
        que.pop();
        inQ[u] = false;
        for (__typeof(g[u].begin()) it(g[u].begin()); it != g[u].end(); it++) {
          Edge e = E[*it];
          if (e.cap > 0) {
            int nc = c + e.cost;
            if (nc < dist[e.y]) {
              dist[e.y] = nc;
              prev[e.y] = *it;
              am[e.y] = min(am[u], e.cap);
              if (!inQ[e.y]) {
                que.push(e.y);
                inQ[e.y] = true;
              }
            }
          }
        }
      }
      if (maxflow) {
        if (dist[t] == INF) break;
      } else {
        if (dist[t] >= 0) break;
      }
      int z = am[t];
      flow += z;
      cost += z * dist[t];
      for (int i = t; i != s; i = E[prev[i]].x) {
        E[prev[i]].cap -= z, E[prev[i] ^ 1].cap += z;
      }
    }
    return make_pair(flow, cost);
  }
};
int n, m, aa, dd, x;
vector<int> a, c;
string how[101];
int notall() {
  minCostMaxFlow *net = new minCostMaxFlow(m + n + 2);
  int s = 0, t = 1;
  for (int i = 0; i < n; i++) {
    net->addEdge(s, i + 2, 1, 0);
  }
  for (int i = 0; i < m; i++) {
    net->addEdge(n + 2 + i, t, 1, 0);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (c[j] > a[i] && how[i] == "ATK") {
        net->addEdge(i + 2, n + 2 + j, 1, -(c[j] - a[i]));
      }
    }
  }
  return -net->mcmf(s, t, false).second;
}
int all() {
  minCostMaxFlow *net = new minCostMaxFlow(m + m + 2);
  int s = 0, t = 1;
  for (int i = 0; i < m; i++) {
    net->addEdge(s, i + 2, 1, 0);
  }
  for (int i = 0; i < m; i++) {
    net->addEdge(m + 2 + i, t, 1, 0);
  }
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < m; ++j) {
      if (i < n) {
        if (how[i] == "ATK") {
          if (c[j] >= a[i]) net->addEdge(i + 2, m + 2 + j, 1, -(c[j] - a[i]));
        } else {
          if (c[j] > a[i]) net->addEdge(i + 2, m + 2 + j, 1, 0);
        }
      } else {
        net->addEdge(i + 2, m + 2 + j, 1, -c[j]);
      }
    }
  }
  pair<int, int> ret = net->mcmf(s, t, true);
  if (ret.first == m) return -ret.second;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> how[i] >> x;
    a.push_back(x);
  }
  for (int i = 0; i < m; i++) {
    cin >> x;
    c.push_back(x);
  }
  int res = notall();
  if (m > n) {
    res = max(res, all());
  }
  cout << res << "\n";
  return 0;
}
