#include <bits/stdc++.h>
using namespace std;
const int MAX = 105, INF = 1e9;
int n, m, l, r, a[MAX], at[MAX], def[MAX], dp[MAX][MAX][MAX][2];
char s[5];
int F(int i, int x, int y, int b) {
  if (i > m) {
    if (b == 1) {
      if (x > l && y > r) return 0;
      return -INF;
    }
    return 0;
  }
  if (dp[i][x][y][b] != -1) return dp[i][x][y][b];
  int ans = F(i + 1, x, y, b);
  if (x <= l && a[i] >= at[x])
    ans = max(ans, F(i + 1, x + 1, y, b) + a[i] - at[x]);
  if (y <= r && a[i] > def[y]) ans = max(ans, F(i + 1, x, y + 1, b));
  if (b == 1) ans = max(ans, F(i + 1, x, y, b) + a[i]);
  return dp[i][x][y][b] = ans;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%s%d", &s, &x);
    if (s[0] == 'A')
      at[++l] = x;
    else
      def[++r] = x;
  }
  for (int i = 1; i <= m; i++) scanf("%d", &a[i]);
  sort(a + 1, a + m + 1);
  sort(at + 1, at + l + 1);
  sort(def + 1, def + r + 1);
  memset(dp, -1, sizeof(dp));
  printf("%d\n", max(F(1, 1, 1, 0), F(1, 1, 1, 1)));
  return 0;
}
