#include <bits/stdc++.h>
using namespace std;
void io(bool ok) { freopen("input.txt", "r", stdin); }
int main() {
  int a, b;
  cin >> a >> b;
  int num[b];
  string s[a];
  for (int i = 0; i < a; i++) cin >> s[i];
  for (int i = 0; i < b; i++) scanf("%d", &num[i]);
  int sum = 0;
  for (int i = 0; i < b; i++) {
    int cnt[5] = {0, 0, 0, 0, 0};
    int mx = -1;
    for (int j = 0; j < a; j++) {
      cnt[s[j][i] - 65]++;
      mx = max(cnt[s[j][i] - 65], mx);
    }
    sum = sum + mx * num[i];
  }
  printf("%d", sum);
  return 0;
}
