#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, m = 0;
  char c;
  string str[1001];
  int arr[1001];
  int sum = 0;
  int maximum = 0;
  cin >> n >> m;
  int k = 0;
  for (int i = 0; i < n; i++) {
    cin >> str[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < m; i++) {
    int count[5];
    for (int j = 0; j < 5; j++) {
      count[j] = 0;
    }
    for (int j = 0; j < n; j++) {
      c = str[j][i];
      k = c;
      k -= 65;
      count[k]++;
    }
    maximum = count[0];
    for (int j = 0; j < 4; j++) {
      maximum = max(maximum, count[j + 1]);
    }
    sum += (arr[i] * maximum);
  }
  cout << sum << endl;
  return 0;
}
