#include <bits/stdc++.h>
using namespace std;
bool comp(int a, int b) { return a < b; }
int main() {
  int n, m, a = 0, b = 0, c = 0, d = 0, e = 0, max_point = 0;
  vector<string> answers;
  vector<int> points;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string ans;
    cin >> ans;
    answers.push_back(ans);
  }
  for (int i = 0; i < m; i++) {
    int ai;
    cin >> ai;
    points.push_back(ai);
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (answers[j][i] == 'A') {
        a++;
      }
      if (answers[j][i] == 'B') {
        b++;
      }
      if (answers[j][i] == 'C') {
        c++;
      }
      if (answers[j][i] == 'D') {
        d++;
      }
      if (answers[j][i] == 'E') {
        e++;
      }
    }
    max_point = max_point + points[i] * max({a, b, c, d, e}, comp);
    a = 0;
    b = 0;
    c = 0;
    d = 0;
    e = 0;
  }
  cout << max_point;
  return 0;
}
