#include <bits/stdc++.h>
using namespace std;
stack<char> stk;
vector<long long> vc, vc1, vc2;
long long a, b, c, d, e, f, g, h, cnt, bnt, p, sum;
string s, cal;
long long arr[1000][6];
char ch;
bool ok = true;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> a >> b;
  for (int i = 0; i < a; ++i) {
    for (int j = 0; j < b; ++j) {
      cin >> ch;
      arr[j][ch - 'A']++;
    }
  }
  for (int i = 0; i < b; ++i) {
    cin >> e;
    for (int j = 0; j < 5; ++j) {
      cnt = max(cnt, arr[i][j]);
    }
    bnt += cnt * e;
    cnt = 0;
  }
  cout << bnt;
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  return 0;
}
