#include <bits/stdc++.h>
using namespace std;
long long n, m;
map<char, long long> answers[1010];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    answers[i]['A'] = 0;
    answers[i]['B'] = 0;
    answers[i]['C'] = 0;
    answers[i]['D'] = 0;
    answers[i]['E'] = 0;
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      char s;
      cin >> s;
      answers[j][s]++;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < m; i++) {
    long long x;
    cin >> x;
    long long maximum = max({answers[i]['A'], answers[i]['B'], answers[i]['C'],
                             answers[i]['D'], answers[i]['E']});
    ans += x * maximum;
  }
  cout << ans;
  return 0;
}
