#include <bits/stdc++.h>
using namespace std;
long long getmax(long long arr[]) {
  long long m = 0;
  for (long long i = 0; i < 26; i++) {
    m = max(m, arr[i]);
  }
  return m;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  string arr[n];
  long long alpha[26];
  long long res = 0;
  for (long long i = 0; i < n; i++) cin >> arr[i];
  long long marks[m];
  for (long long i = 0; i < m; i++) cin >> marks[i];
  for (long long i = 0; i < m; i++) {
    memset(alpha, 0, sizeof(alpha));
    for (long long j = 0; j < n; j++) {
      int k = arr[j][i] - 'A';
      alpha[k]++;
    }
    long long c = getmax(alpha);
    res += c * marks[i];
  }
  cout << res << '\n';
}
