#include <bits/stdc++.h>
using namespace std;
int main() {
  char ar[1005][1005];
  int ar1[1005], c = 1, sum = 0, ar2[5] = {0}, maxm = 0;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  for (int i = 0; i < m; i++) cin >> ar1[i];
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (ar[j][i] == 'A') ar2[0]++;
      if (ar[j][i] == 'B') ar2[1]++;
      if (ar[j][i] == 'C') ar2[2]++;
      if (ar[j][i] == 'D') ar2[3]++;
      if (ar[j][i] == 'E') ar2[4]++;
    }
    for (int i = 0; i < 5; i++) {
      if (ar2[i] > maxm) maxm = ar2[i];
      ar2[i] = 0;
    }
    sum = sum + (maxm * ar1[i]);
    maxm = 0;
  }
  cout << sum << endl;
}
