#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int A[N][10], v[N];
char s[N];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    for (int j = 0; j < m; j++) {
      A[j][s[j] - 'A']++;
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    scanf("%d", &v[i]);
  }
  for (int i = 0; i < m; i++) {
    int mx = 1;
    for (int j = 0; j < 5; j++) {
      mx = max(mx, A[i][j]);
    }
    ans += mx * v[i];
  }
  printf("%d\n", ans);
}
