#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  string s[n];
  for (int i = 0; i < n; i++) cin >> s[i];
  int cnt[5] = {0};
  int point = 0;
  int pt;
  for (int i = 0; i < m; i++) {
    cin >> pt;
    for (int j = 0; j < n; j++) {
      if (s[j][i] == 'A')
        cnt[0]++;
      else if (s[j][i] == 'B')
        cnt[1]++;
      else if (s[j][i] == 'C')
        cnt[2]++;
      else if (s[j][i] == 'D')
        cnt[3]++;
      else if (s[j][i] == 'E')
        cnt[4]++;
    }
    point += pt * max(cnt[0], max(cnt[1], max(cnt[2], max(cnt[3], cnt[4]))));
    cnt[0] = cnt[1] = cnt[2] = cnt[3] = cnt[4] = 0;
  }
  cout << point << endl;
}
