#include <bits/stdc++.h>
int main(int argc, char const *argv[]) {
  int n, m;
  int total = 0;
  scanf("%d %d", &n, &m);
  char str[n][m + 1];
  int pts[m];
  int arr_cnt[5];
  for (int i = 0; i < n; ++i) {
    scanf("%s", str[i]);
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d", &pts[i]);
  }
  for (int i = 0; i < m; ++i) {
    for (int i = 0; i < 5; ++i) {
      arr_cnt[i] = 0;
    }
    for (int j = 0; j < n; ++j) {
      if (str[j][i] == 'A') {
        arr_cnt[0]++;
      } else if (str[j][i] == 'B') {
        arr_cnt[1]++;
      } else if (str[j][i] == 'C') {
        arr_cnt[2]++;
      } else if (str[j][i] == 'D') {
        arr_cnt[3]++;
      } else {
        arr_cnt[4]++;
      }
    }
    int max = arr_cnt[0];
    int index = 0;
    for (int k = 0; k < 5; ++k) {
      if (arr_cnt[k] > max) {
        max = arr_cnt[k];
        index = k;
      }
    }
    total += max * pts[i];
  }
  printf("%d", total);
  return 0;
}
