#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
const int MAXN = 1e3 + 10;
using namespace std;
char str[MAXN][MAXN];
int data[MAXN];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> str[i];
  for (int i = 0; i < m; i++) cin >> data[i];
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    int temp[10] = {0}, tmp = -1;
    for (int j = 0; j < n; j++) temp[str[j][i] - 'A']++;
    for (int j = 0; j < 5; j++) tmp = max(tmp, temp[j]);
    ans += (long long)tmp * data[i];
  }
  cout << ans << endl;
  return 0;
}
