#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  char str[n][m];
  for (long long i = 0; i <= n - 1; i++) {
    for (long long j = 0; j <= m - 1; j++) cin >> str[i][j];
  }
  long long marks[m];
  for (long long i = 0; i <= m - 1; i++) cin >> marks[i];
  long long count = 0;
  for (long long j = 0; j <= m - 1; j++) {
    long long a = 0, b = 0, c = 0, d = 0, e = 0;
    for (long long i = 0; i <= n - 1; i++) {
      if (str[i][j] == 'A') a++;
      if (str[i][j] == 'B') b++;
      if (str[i][j] == 'C') c++;
      if (str[i][j] == 'D') d++;
      if (str[i][j] == 'E') e++;
    }
    count += (max(a, max(b, max(c, max(d, e)))) * marks[j]);
  }
  cout << count;
  return 0;
}
