#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  vector<string> v;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  long long int arr[10000];
  for (int i = 1; i <= k; i++) {
    cin >> arr[i];
  }
  long long int mx = 0;
  map<char, long long int> mp;
  long long int brr[27], ans = 0;
  for (int i = 0; i < k; i++) {
    for (int l = 0; l <= 26; l++) brr[l] = 0;
    for (int j = 0; j < n; j++) {
      brr[v[j][i] - 'A']++;
      mx = max(mx, brr[v[j][i] - 'A']);
    }
    ans += (arr[i + 1] * mx);
    mx = 0;
  }
  cout << ans << endl;
  return 0;
}
