#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int m, n;
  cin >> n >> m;
  int arr[m][5];
  for (int i = 0; i < m; i++) {
    arr[i][0] = 0;
    arr[i][1] = 0;
    arr[i][2] = 0;
    arr[i][3] = 0;
    arr[i][4] = 0;
  }
  string str;
  for (int i = 0; i < n; i++) {
    cin >> str;
    for (int j = 0; j < m; j++) {
      switch (str[j]) {
        case 'A':
          arr[j][0]++;
          break;
        case 'B':
          arr[j][1]++;
          break;
        case 'C':
          arr[j][2]++;
          break;
        case 'D':
          arr[j][3]++;
          break;
        case 'E':
          arr[j][4]++;
          break;
      }
    }
  }
  int a;
  int ans = 0;
  for (int i = 0; i < m; i++) {
    cin >> a;
    int max = arr[i][0];
    for (int j = 1; j < 5; j++) {
      if (max < arr[i][j]) {
        max = arr[i][j];
      }
    }
    ans += (a * max);
  }
  cout << ans << endl;
}
