#include <bits/stdc++.h>
using namespace std;
int factorial(int n);
int factorial(int n) {
  if (n == 1) {
    return 1;
  } else {
    return n * factorial(n - 1);
  }
}
bool is_prime(long long n) {
  if (n == 1) {
    return false;
  }
  long long i = 2;
  while (i * i <= n) {
    if (n % i == 0) {
      return false;
    }
    i += 1;
  }
  return true;
}
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int check(int x, vector<int> a, int n) {
  int county = 0;
  map<int, int> mapa;
  for (int i = 0; i < n; i++) {
    mapa.insert(pair<int, int>(a[i], 0));
  }
  for (int i = 0; i < n; i++) {
    mapa[a[i]]++;
  }
  for (int i = 0; i < a.size(); i++) {
    mapa[a[i]]--;
    if (mapa[abs(a[i] - x)] > 0) {
      county++;
      mapa[abs(a[i] - x)]--;
    }
  }
  return county;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  string s[n];
  for (int i = 0; i < n; i++) {
    string t;
    cin >> t;
    s[i] = t;
  }
  vector<int> a(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  long long sum = 0;
  for (int j = 0; j < m; j++) {
    map<char, int> mapa;
    mapa.insert(pair<char, int>('A', 0));
    mapa.insert(pair<char, int>('B', 0));
    mapa.insert(pair<char, int>('C', 0));
    mapa.insert(pair<char, int>('D', 0));
    mapa.insert(pair<char, int>('E', 0));
    for (int i = 0; i < n; i++) {
      mapa[s[i][j]]++;
    }
    map<char, int>::iterator it = mapa.begin();
    int maxi = 0;
    while (it != mapa.end()) {
      if (it->second > maxi) {
        maxi = it->second;
      }
      it++;
    }
    sum = sum + maxi * a[j];
  }
  cout << sum << endl;
}
