#include <bits/stdc++.h>
using namespace std;
pair<int, int> b[105];
int a[105];
bool used[105];
int main() {
  int n, m;
  cin >> n >> m;
  string sss;
  for (int i = 0; i < n; i++) {
    cin >> sss >> b[i].second;
    b[i].first = (int)(sss[0] == 'D');
  }
  sort(b, b + n);
  for (int i = 0; i < m; i++) cin >> a[i];
  sort(a, a + m);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    memset(used, false, sizeof used);
    int temp = 0;
    bool ok = true;
    for (int j = 0; ok && j <= i; j++)
      if (b[j].first) {
        int t = -1;
        for (int k = 0; k < m; k++)
          if (!used[k] && a[k] > b[j].second) {
            t = k;
            break;
          }
        if (t < 0)
          ok = false;
        else
          used[t] = true;
      }
    for (int j = i; ok && j >= 0; j--)
      if (!b[j].first) {
        int t = -1;
        for (int k = m - 1; k >= 0; k--)
          if (!used[k] && a[k] >= b[j].second) {
            t = k;
            break;
          }
        if (t < 0)
          ok = false;
        else {
          used[t] = true;
          temp += a[t] - b[j].second;
        }
      }
    if (!ok) continue;
    if (i == n - 1) {
      for (int k = 0; k < m; k++)
        if (!used[k]) temp += a[k];
    }
    if (temp > ans) ans = temp;
  }
  cout << ans << endl;
  return 0;
}
