#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll INFll = 1ll * 1000000009 * 1000000009;
const long double PI =
    3.141592653589793238462643383279502884197169399375105820974944;
ll gcd(ll a, ll b) { return (b == 0) ? a : gcd(b, a % b); }
int main() {
  ll a, b;
  cin >> a >> b;
  string s;
  vector<vector<ll> > q;
  q.resize(b);
  for (ll i = 0; i < a; i++) {
    cin >> s;
    for (ll j = 0; j < s.size(); j++) {
      if (q[j].size() == 0) q[j].resize(5);
      q[j][s[j] - 'A']++;
    }
  }
  ll sol[b];
  for (ll i = 0; i < b; i++) {
    cin >> sol[i];
  }
  ll maxi = 0;
  for (ll i = 0; i < b; i++) {
    sort(q[i].begin(), q[i].end());
    maxi += q[i][q[i].size() - 1] * sol[i];
  }
  cout << maxi << endl;
  return 0;
}
