#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<string> v;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  int marks[m];
  for (int i = 0; i < m; i++) {
    cin >> marks[i];
  }
  int maxm[5];
  int res = 0;
  for (int i = 0; i < m; i++) {
    int op[5] = {0};
    for (int j = 0; j < n; j++) {
      op[v[j][i] - 'A']++;
    }
    int maxm = 1;
    for (int k = 0; k < 5; k++) {
      maxm = max(maxm, op[k]);
    }
    res += maxm * marks[i];
  }
  cout << res << endl;
}
int main() {
  solve();
  return 0;
}
