#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int cnt[1001][5] = {0};
  int a[1001];
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) cnt[j][s[j] - 'A']++;
  }
  for (int i = 0; i < m; i++) cin >> a[i];
  int maxn = 0, ans = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 5; j++) {
      if (cnt[i][j] > maxn) maxn = cnt[i][j];
    }
    ans += maxn * a[i];
    maxn = 0;
  }
  cout << ans;
  return 0;
}
