#include <bits/stdc++.h>
using namespace std;
int main() {
  int count[6][1005];
  memset(count, 0, sizeof(count));
  int n, m;
  cin >> n >> m;
  char s[1005];
  for (int i = 1; i <= n; i++) {
    cin >> s;
    for (int j = 0; j <= m - 1; j++) {
      if (s[j] == 'A') count[1][j]++;
      if (s[j] == 'B') count[2][j]++;
      if (s[j] == 'C') count[3][j]++;
      if (s[j] == 'D') count[4][j]++;
      if (s[j] == 'E') count[5][j]++;
    }
  }
  int ans = 0;
  for (int i = 0; i <= m - 1; i++) {
    int score;
    cin >> score;
    int maxn = 0;
    for (int j = 1; j <= 5; j++) maxn = max(count[j][i], maxn);
    ans += maxn * score;
  }
  cout << ans << endl;
  return 0;
}
