#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007LL;
inline long long max(long long a, int32_t b) { return a > b ? a : b; }
inline long long max(int32_t a, long long b) { return a > b ? a : b; }
inline long long min(long long a, int32_t b) { return a < b ? a : b; }
inline long long min(int32_t a, long long b) { return a < b ? a : b; }
long long d4_1[4] = {1, 0, -1, 0};
long long d4_2[4] = {0, 1, 0, -1};
long long d8_1[8] = {1, 1, 1, -1, -1, -1, 0, 0};
long long d8_2[8] = {0, -1, 1, 0, -1, 1, 1, -1};
long long seed;
mt19937 rng(seed = chrono::steady_clock::now().time_since_epoch().count());
inline long long rand(long long l = 0, long long r = 1e18) {
  return uniform_int_distribution<long long>(l, r)(rng);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(10);
  long long t = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    string s[n + 5];
    for (long long i = 0; i < n; i++) cin >> s[i];
    long long arr[m + 5];
    for (long long i = 0; i < m; i++) cin >> arr[i];
    long long ans = 0;
    for (long long i = 0; i < m; i++) {
      long long freq[26] = {0};
      for (long long j = 0; j < n; j++) {
        freq[s[j][i] - 'A']++;
      }
      long long x = 0;
      for (long long k = 0; k < 26; k++) x = max(x, freq[k]);
      ans += x * arr[i];
    }
    cout << ans;
  }
}
