#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string st[n];
  int a[m];
  for (int i = 0; i < n; i++) {
    cin >> st[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  int maxa = 0;
  int ca, cb, cc, cd, ce;
  for (int i = 0; i < m; i++) {
    ca = 0;
    cb = 0;
    cc = 0;
    cd = 0;
    ce = 0;
    for (int j = 0; j < n; j++) {
      if (st[j][i] == 'A') ca++;
      if (st[j][i] == 'B') cb++;
      if (st[j][i] == 'C') cc++;
      if (st[j][i] == 'D') cd++;
      if (st[j][i] == 'E') ce++;
    }
    int x1 = max(ca, cb);
    int x2 = max(cc, cd);
    int x3 = max(max(x1, x2), ce);
    maxa += x3 * a[i];
  }
  cout << maxa << endl;
  return 0;
}
