#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, total = 0;
  cin >> n >> m;
  vector<string> vect(n);
  for (auto &i : vect) cin >> i;
  vector<int> marks(m);
  for (auto &i : marks) cin >> i;
  for (size_t i = 0; i < m; i++) {
    int a, b, c, d, e;
    a = b = c = d = e = 0;
    for (auto j : vect) {
      if (j[i] == 'A')
        a++;
      else if (j[i] == 'B')
        b++;
      else if (j[i] == 'C')
        c++;
      else if (j[i] == 'D')
        d++;
      else if (j[i] == 'E')
        e++;
    }
    total += max(a, max(b, max(c, max(d, e)))) * marks[i];
  }
  cout << total << endl;
  return 0;
}
