#include <bits/stdc++.h>
using namespace std;
long long n, a, m, cnt = 1, sum, mx;
map<char, long long> mp;
int main() {
  cin >> n >> m;
  char arr[n][m];
  long long a[m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> arr[i][j];
  for (int i = 0; i < m; i++) cin >> a[i];
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < n; j++) {
      mp[arr[j][i]]++;
    }
    for (char j = 'A'; j <= 'E'; j++) {
      mx = max(mx, mp[j]);
    }
    mp.clear();
    sum += mx * a[i];
    mx = 0;
  }
  cout << sum;
}
