#include <bits/stdc++.h>
using namespace std;
void FindAndReplaceAll(string& src, const string& from, const string& to) {
  string::size_type start_pos = src.find(from);
  while ((start_pos = src.find(from, start_pos)) != std::string::npos) {
    src.replace(start_pos, from.length(), to);
    start_pos += to.length();
  }
}
void LOG() { cout << std::endl; }
template <typename First, typename... Rest>
void LOG(First&& first, Rest&&... rest) {
  std::cout << std::forward<First>(first);
  LOG(std::forward<Rest>(rest)...);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<string> vec(n);
  vector<int> points(m);
  for (int i = 0; i < n; ++i) {
    cin >> vec[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> points[i];
  }
  vector<int> mx(5);
  int score = 0;
  for (int i = 0; i < m; ++i) {
    int max_ans = 0;
    for (int j = 0; j < n; ++j) {
      char a = vec[j][i];
      ++mx[a - 'A'];
      if (mx[a - 'A'] > mx[max_ans]) {
        max_ans = a - 'A';
      }
    }
    score += points[i] * mx[max_ans];
    fill(mx.begin(), mx.end(), 0);
  }
  LOG(score);
  return 0;
}
