#include <bits/stdc++.h>
using namespace std;
int n, m;
string s;
int a[110], b[110], d[110];
int an, bn;
int dp[110][110][110][2];
bool v[110][110][110][2] = {};
int ans;
bool cmp(int x, int y) { return x < y; }
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    if (s == "ATK") {
      an++;
      cin >> a[an];
    } else {
      bn++;
      cin >> b[bn];
    }
  }
  for (int i = 1; i <= m; i++) {
    cin >> d[i];
  }
  sort(a + 1, a + an + 1, cmp);
  sort(b + 1, b + bn + 1, cmp);
  sort(d + 1, d + m + 1, cmp);
  v[0][0][0][0] = 1;
  v[0][0][0][1] = 1;
  for (int i = 0; i <= m; i++) {
    for (int u = 0; u <= 1; u++) {
      for (int j = 0; j <= an; j++) {
        for (int k = 0; k <= bn; k++) {
          if (v[i][j][k][u] == 0) continue;
          if (u == 0) ans = max(dp[i][j][k][u], ans);
          if (u == 1 && j == an && k == bn) ans = max(dp[i][j][k][u], ans);
          dp[i + 1][j][k][u] = max(dp[i + 1][j][k][u], dp[i][j][k][u]);
          if (j < an && d[i + 1] >= a[j + 1]) {
            dp[i + 1][j + 1][k][u] = max(dp[i + 1][j + 1][k][u],
                                         dp[i][j][k][u] + d[i + 1] - a[j + 1]);
            v[i + 1][j + 1][k][u] = 1;
          }
          if (k < bn && d[i + 1] > b[k + 1]) {
            dp[i + 1][j][k + 1][u] =
                max(dp[i + 1][j][k + 1][u], dp[i][j][k][u]);
            v[i + 1][j][k + 1][u] = 1;
          }
          if ((j == an && k == bn) || u == 1) {
            dp[i + 1][j][k][u] =
                max(dp[i + 1][j][k][u], dp[i][j][k][u] + d[i + 1]);
            v[i + 1][j][k][u] = 1;
          }
          dp[i + 1][j][k][u] = max(dp[i + 1][j][k][u], dp[i][j][k][u]);
          v[i + 1][j][k][u] = 1;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
