#include <bits/stdc++.h>
using namespace std;
int delta[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
long long calc_pow(long long a, long long p, long long m = 1000000007) {
  long long res = 1;
  while (p > 0) {
    if (p & 1) res = (res * a) % m;
    a = (a * a) % m;
    p >>= 1;
  }
  return res;
}
long long calc_pow_without_mod(long long a, long long p) {
  long long res = 1;
  while (p > 0) {
    if (p & 1) res = res * a;
    a = a * a;
    p >>= 1;
  }
  return res;
}
void func() {
  int n, m;
  cin >> n >> m;
  vector<string> v;
  string s;
  for (int i = 1; i <= (n); i++) {
    cin >> s;
    v.push_back(s);
  }
  int arr[m + 1];
  for (int i = 1; i <= (m); i++) cin >> arr[i];
  int ans = 0;
  for (int i = 0; i < m; i++) {
    unordered_map<char, int> mm;
    for (int j = 0; j < n; j++) {
      mm[v[j][i]]++;
    }
    int val = 0;
    for (auto &it : (mm)) val = max(val, it.second);
    ans += val * arr[i + 1];
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  func();
  return 0;
}
