#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int m, n;
  cin >> n >> m;
  vector<string> s(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  vector<long long int> point(m);
  for (int i = 0; i < m; i++) cin >> point[i];
  long long int sum = 0;
  for (int i = 0; i < m; i++) {
    long long int a = 0, b = 0, c = 0, d = 0, e = 0;
    for (int j = 0; j < n; j++) {
      switch (s[j][i]) {
        case 'A':
          a++;
          break;
        case 'B':
          b++;
          break;
        case 'C':
          c++;
          break;
        case 'D':
          d++;
          break;
        case 'E':
          e++;
          break;
      }
    }
    sum += point[i] * (max(a, max(b, max(c, max(d, e)))));
  }
  cout << sum << endl;
  return 0;
}
