#include <bits/stdc++.h>
using namespace std;
const int N = 105;
vector<int> a, d, v;
int dp[N][N][N][2], INF = 1e9;
int solve(int i, int j, int k, bool f) {
  if (i == v.size()) {
    if (f && (j < a.size() || k < d.size())) return -INF;
    return 0;
  }
  int &ret = dp[i][j][k][f];
  if (~ret) return ret;
  ret = solve(i + 1, j, k, 1) + v[i];
  ret = max(ret, solve(i + 1, j, k, f));
  if (j < a.size() && v[i] >= a[j])
    ret = max(ret, solve(i + 1, j + 1, k, f) + v[i] - a[j]);
  if (k < d.size() && v[i] > d[k]) ret = max(ret, solve(i + 1, j, k + 1, f));
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, ans = 0, sum = 0;
  memset(dp, -1, sizeof dp);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string s;
    int x;
    cin >> s >> x;
    if (s == "ATK")
      a.push_back(x);
    else
      d.push_back(x);
  }
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  sort(d.begin(), d.end());
  sort(v.begin(), v.end());
  sort(a.begin(), a.end());
  ans = solve(0, 0, 0, 0);
  cout << ans << endl;
  return 0;
}
