#include <bits/stdc++.h>
using namespace std;
void see(int x) { cout << x; }
void see(long long int x) { cout << x; }
void see(long double x) { cout << x; }
void see(char x) { cout << '\'' << x << '\''; }
void see(string x) { cout << '\"' << x << '\"'; }
template <typename T, typename V>
void see(const pair<T, V> &x) {
  cout << '{';
  see(x.first);
  cout << ',';
  see(x.second);
  cout << '}';
}
template <typename T>
void see(const T &x) {
  int f = 0;
  cout << '{';
  for (auto &i : x) cout << (f++ ? "," : ""), see(i);
  cout << "}";
}
void _print() { cout << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  see(t);
  if (sizeof...(v)) cout << ", ";
  _print(v...);
}
long long int gcd(long long int a, long long int b) {
  return (!b) ? a : gcd(b, a % b);
}
int n, m;
string s[1005];
int cnt[1005][27];
int a[1005];
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> s[i];
  for (int i = 1; i <= m; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cnt[j][s[i][j - 1] - 'A'] += 1;
    }
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    int mx = 0;
    for (int j = 0; j <= 25; j++) mx = max(mx, cnt[i][j]);
    ans += mx * a[i];
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
