#include <bits/stdc++.h>
using namespace std;
signed main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<string> v;
  vector<int> marks;
  string x;
  int y;
  int a[5];
  for (int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  for (int i = 0; i < m; i++) {
    cin >> y;
    marks.push_back(y);
  }
  int sum = 0;
  for (int i = 0; i < m; i++) {
    int max = 0;
    a[0] = 0, a[1] = 0;
    a[2] = 0;
    a[3] = 0, a[4] = 0;
    for (int j = 0; j < n; j++) {
      if (v[j][i] == 'A')
        a[0]++;
      else if (v[j][i] == 'B')
        a[1]++;
      else if (v[j][i] == 'C')
        a[2]++;
      else if (v[j][i] == 'D')
        a[3]++;
      else if (v[j][i] == 'E')
        a[4]++;
    }
    max = *max_element(a, a + 5);
    sum += max * marks[i];
  }
  cout << sum;
}
