#include <bits/stdc++.h>
using namespace std;
int a[1005][7];
int p[1005];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      if (s[j] == 'A')
        a[j][1]++;
      else if (s[j] == 'B')
        a[j][2]++;
      else if (s[j] == 'C')
        a[j][3]++;
      else if (s[j] == 'D')
        a[j][4]++;
      else
        a[j][5]++;
    }
  }
  int cnt = 0;
  for (int i = 0; i < m; i++) cin >> p[i];
  for (int i = 0; i < m; i++) {
    int ans = -1;
    for (int j = 1; j <= 5; j++) {
      ans = max(ans, a[i][j]);
    }
    cnt += (ans * p[i]);
  }
  cout << cnt;
}
