#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, gg;
  char s[1010][1010];
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) cin >> s[i];
  int ans = 0;
  for (int j = 0; j < m; j++) {
    scanf("%d", &gg);
    int suma = 0, sumb = 0, sumc = 0, sumd = 0, sume = 0;
    for (int i = 0; i < n; i++) {
      if (s[i][j] == 'A') suma++;
      if (s[i][j] == 'B') sumb++;
      if (s[i][j] == 'C') sumc++;
      if (s[i][j] == 'D') sumd++;
      if (s[i][j] == 'E') sume++;
    }
    int maxx1 = max(suma, sumb);
    int maxx2 = max(sumc, sumd);
    int maxx3 = max(maxx1, maxx2);
    int maxx = max(maxx3, sume);
    ans = ans + maxx * gg;
  }
  printf("%d\n", ans);
  return 0;
}
