#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long int gcd(long long int a, long long int b) {
  while (a != 0 and b != 0) {
    if (a >= b)
      a = a % b;
    else if (b > a)
      b = b % a;
  }
  if (a >= b)
    return a;
  else
    return b;
}
long long int fast_pow(long long int base, long long int p) {
  long long int a = 1;
  while (p > 0) {
    if (p % 2 == 0) {
      p /= 2;
      base *= base;
    } else {
      p--;
      a = a * 1LL * base;
    }
    a %= mod;
    base %= mod;
  }
  return a;
}
long long int t, n, m, k, idx, ct1, ct0;
void solve() {
  cin >> n >> m;
  vector<string> s;
  string S;
  for (int i = 0; i < n; i++) {
    cin >> S;
    s.push_back(S);
  }
  vector<long long int> a(m, 0);
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  vector<vector<long long int> > ct(m, vector<long long int>(5, 0));
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      ct[i][s[j][i] - 'A']++;
    }
  }
  long long int mx = -1;
  long long int res(0);
  for (int i = 0; i < m; i++) {
    mx = -1;
    for (int j = 0; j < 5; j++) {
      mx = max(ct[i][j], mx);
    }
    res += mx * a[i];
  }
  cout << res << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  t = 1;
  while (t--) {
    solve();
  }
}
