#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& out, vector<T> a) {
  for (int i = (int)(0); i < (int)((int)a.size()); i++)
    out << a[i] << (i != (int)a.size() - 1 ? " " : "\n");
  return out;
}
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.fi >> a.se;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2>& a) {
  out << a.fi << " " << a.se;
  return out;
}
struct fastio {
  fastio() {
    string filename = "";
    if (filename.size()) {
      string inp = filename + ".in";
      string out = filename + ".out";
      freopen(inp.c_str(), "r", stdin);
      freopen(out.c_str(), "w", stdout);
    }
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << showpoint;
    cout << setprecision(12);
    cout << fixed;
    cerr << showpoint;
    cerr << setprecision(3);
    cerr << fixed;
  }
} _____;
const int MAX = 2e5 + 10;
const long long INF = 1e9 + 10;
const long double EPS = 1e-8;
const long long MOD = 1e9 + 7;
string ans[1010];
long long cnt[1010][(int)'Z'];
void solve() {
  long long n, m;
  cin >> n >> m;
  for (int i = (int)(0); i < (int)(n); i++)
    for (int j = (int)(0); j < (int)(m); j++) {
      char c;
      cin >> c;
      cnt[j][(int)c]++;
    }
  long long summ = 0;
  for (int i = (int)(0); i < (int)(m); i++) {
    long long a;
    cin >> a;
    long long maxx = 0;
    for (int j = (int)('A'); j < (int)('Z' + 1); j++)
      maxx = max(maxx, cnt[i][j]);
    summ += maxx * a;
  }
  cout << summ << endl;
}
int main() {
  solve();
  return 0;
}
