#include <bits/stdc++.h>
namespace solution {
class SolutionInterface {
 public:
  virtual int run() = 0;

 protected:
  virtual void pre_calc() {}
  virtual bool action() = 0;
  virtual void init(){};
  virtual bool input() { return false; };
  virtual void output(){};
  SolutionInterface() {}

 private:
};
}  // namespace solution
namespace solution {
class SolutionBase : public SolutionInterface {
 public:
  virtual int run() {
    pre_calc();
    while (action())
      ;
    return 0;
  }
};
}  // namespace solution
namespace solution {}
namespace solution {
using namespace std;
}
namespace solution {
const int SIZE = 100 + 11;
const int OFF = 0;
const int ON = 1;
const long long DP_NONE = -100;
const long long NONE = std::numeric_limits<long long>::min() / 2;
int n, m;
string jiro_p[SIZE];
int jiro_s[SIZE];
int ciel_s[SIZE];
int jiro_def_s[SIZE];
int jiro_def_s_num;
int jiro_atk_s[SIZE];
int jiro_atk_s_num;
long long dp[SIZE][SIZE][SIZE][2];
long long result;
}  // namespace solution
namespace solution {
class Solver {
 public:
  void solve() {
    split_jiro();
    sort_cards();
    result = calc_maximum_damages();
  }
  void sort_cards() {
    std::sort(jiro_def_s, jiro_def_s + jiro_def_s_num);
    std::sort(jiro_atk_s, jiro_atk_s + jiro_atk_s_num);
    std::sort(ciel_s, ciel_s + m);
  }
  long long calc_maximum_damages() {
    return std::max(rec(0, 0, 0, OFF), rec(0, 0, 0, ON));
  }
  long long rec(int jiro_atk, int jiro_def, int ciel, int flag) {
    long long& res = dp[jiro_atk][jiro_def][ciel][flag];
    if (res != DP_NONE) return res;
    if (ciel >= m) {
      if (flag == ON &&
          (jiro_atk < jiro_atk_s_num || jiro_def < jiro_def_s_num)) {
        return res = NONE;
      }
      return res = 0;
    }
    long long ret = NONE;
    ret = max(ret, rec(jiro_atk, jiro_def, ciel + 1, flag));
    ret = max(ret, rec(jiro_atk, jiro_def, ciel + 1, ON) + ciel_s[ciel]);
    if (jiro_atk < jiro_atk_s_num && ciel_s[ciel] >= jiro_atk_s[jiro_atk]) {
      ret = max(ret, rec(jiro_atk + 1, jiro_def, ciel + 1, flag) +
                         ciel_s[ciel] - jiro_atk_s[jiro_atk]);
    }
    if (jiro_def < jiro_def_s_num && ciel_s[ciel] > jiro_def_s[jiro_def]) {
      ret = max(ret, rec(jiro_atk, jiro_def + 1, ciel + 1, flag));
    }
    return res = ret;
  }
  void split_jiro() {
    for (int i = 0; i < n; ++i) {
      if (jiro_p[i] == "ATK") {
        jiro_atk_s[jiro_atk_s_num++] = jiro_s[i];
      } else {
        jiro_def_s[jiro_def_s_num++] = jiro_s[i];
      }
    }
  }

 private:
};
}  // namespace solution
namespace solution {
class Solution : public SolutionBase {
 public:
 protected:
  virtual bool action() {
    init();
    if (!input()) return false;
    solver.solve();
    output();
    return true;
  }
  void init() {
    for (int i = 0; i < SIZE; ++i)
      for (int j = 0; j < SIZE; ++j)
        for (int k = 0; k < SIZE; ++k)
          for (int l = 0; l < 2; ++l) dp[i][j][k][l] = DP_NONE;
    jiro_atk_s_num = 0;
    jiro_def_s_num = 0;
  }
  bool input() {
    if (!(cin >> n >> m)) return false;
    for (int i = 0; i < n; ++i) {
      cin >> jiro_p[i] >> jiro_s[i];
    }
    for (int i = 0; i < m; ++i) {
      cin >> ciel_s[i];
    }
    return true;
  }
  void output() { cout << result << endl; }

 private:
  Solver solver;
};
}  // namespace solution
int main() { return solution::Solution().run(); }
