#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  void solve(std::istream& in, std::ostream& out) {
    vector<int> jerA, jerD, ciel;
    int n, m;
    in >> n >> m;
    string s;
    int p;
    for (int i = 0; i <= n - 1; i++) {
      in >> s >> p;
      if (s == "ATK")
        jerA.push_back(p);
      else
        jerD.push_back(p);
    }
    for (int i = 0; i <= m - 1; i++) {
      in >> p;
      ciel.push_back(p);
    }
    sort((jerA).begin(), (jerA).end());
    sort((jerD).begin(), (jerD).end());
    sort((ciel).begin(), (ciel).end());
    int max1 = 0;
    for (int l = 0; l <= (int)jerA.size() - 1; l++) {
      int r = m - l - 1;
      if (r >= 0 && ciel[r] >= jerA[l]) max1 += (ciel[r] - jerA[l]);
    }
    vector<int> used(m);
    auto search = [&ciel, &used](int x) {
      for (int i = 0; i <= (int)ciel.size() - 1; i++) {
        if (ciel[i] >= x && !used[i]) {
          used[i] = 1;
          return i;
        }
      }
      return -1;
    };
    int max2 = 0;
    for (int i = 0; i <= (int)jerD.size() - 1; i++) {
      int x = jerD[i] + 1;
      int pos = search(x);
      if (pos == -1) {
        out << max1 << '\n';
        return;
      } else
        max2 -= ciel[pos];
    }
    for (int i = 0; i <= (int)jerA.size() - 1; i++) {
      int x = jerA[i];
      if (search(x) == -1) {
        out << max1 << '\n';
        return;
      }
    }
    for (int i = 0; i <= m - 1; i++) max2 += ciel[i];
    for (int i = 0; i <= (int)jerA.size() - 1; i++) max2 -= jerA[i];
    out << max(max1, max2) << '\n';
    return;
  }
};
void solve(std::istream& in, std::ostream& out) {
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  istream& in = cin;
  ostream& out = cout;
  solve(in, out);
  return 0;
}
