#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int arr[m + 5];
  char s[n + 5][m + 5];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < m; i++) cin >> arr[i];
  long long int sum = 0, a = 0, b = 0, c = 0, d = 0, e = 0, mx;
  for (int i = 0; i < m; i++) {
    a = 0;
    b = 0;
    c = 0;
    d = 0;
    e = 0;
    for (int j = 0; j < n; j++) {
      if (s[j][i] == 'A')
        a++;
      else if (s[j][i] == 'B')
        b++;
      else if (s[j][i] == 'C')
        c++;
      else if (s[j][i] == 'D')
        d++;
      else if (s[j][i] == 'E')
        e++;
    }
    mx = max({a, b, c, d, e});
    sum += (mx * arr[i]);
  }
  cout << sum << "\n";
  return 0;
}
