#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int i, j, k1;
  string string[n];
  for (i = 0; i < n; i++) cin >> string[i];
  int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, sum = 0;
  int arr[m];
  for (i = 0; i < m; i++) cin >> arr[i];
  for (i = 0; i < m; i++) {
    c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0;
    for (j = 0; j < n; j++) {
      if (string[j].at(i) == 'A') c1++;
      if (string[j].at(i) == 'B') c2++;
      if (string[j].at(i) == 'C') c3++;
      if (string[j].at(i) == 'D') c4++;
      if (string[j].at(i) == 'E') c5++;
    }
    k1 = max(c1, max(c2, max(c3, max(c4, c5))));
    sum = sum + k1 * arr[i];
  }
  cout << sum;
  return 0;
}
