#include <bits/stdc++.h>
using namespace std;
using namespace std;
vector<long long>::iterator ptr;
long long count = 0;
long long cache[10004];
long long dp[100005] = {0};
long long cnt[200005] = {0};
long long a[200005] = {0};
long long b[200005] = {0};
long long r[200005] = {0};
long long pr(long long n) {
  if (n % 2 == 0) {
    return 2;
  }
  for (long long i = 3; i <= sqrt(n); i = i + 2) {
    if (n % i == 0) return i;
  }
  if (n > 2) return n;
}
long long power(long long x, unsigned long long y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return power(x, y / 2) * power(x, y / 2);
  else
    return x * power(x, y / 2) * power(x, y / 2);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n = 0, p, q = 0, k, x = 0, y, m;
  cin >> n >> m;
  char s[1005][1005];
  long long v[1005][5] = {0};
  for (long long i = 0; i < m; ++i) {
    for (long long j = 0; j < 5; ++j) {
      v[i][j] = 0;
    }
  }
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < m; ++j) {
      cin >> s[i][j];
      if (s[i][j] == 'A')
        v[j][0]++;
      else if (s[i][j] == 'B')
        v[j][1]++;
      else if (s[i][j] == 'C')
        v[j][2]++;
      else if (s[i][j] == 'D')
        v[j][3]++;
      else if (s[i][j] == 'E')
        v[j][4]++;
    }
  }
  for (long long i = 0; i < m; ++i) {
    cin >> a[i];
  }
  for (long long i = 0; i < m; ++i) {
    p = 0;
    for (long long j = 0; j < 5; ++j) {
      p = max(p, v[i][j]);
    }
    x += (a[i] * p);
  }
  cout << x;
  return 0;
}
