#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &s) {
  s = 0;
  register char ch = getchar();
  register int w = 0;
  while (!isdigit(ch)) w |= ch == '-', ch = getchar();
  while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
  if (w) s = -s;
}
namespace Sakii {
int n, m, x[1010][1010], jud[10], ans, maxx, a[1010];
string s;
inline void main() {
  read(n);
  read(m);
  for (int i = 1; i <= n; i++) {
    cin >> s;
    for (int j = 1; j <= m; j++) {
      x[i][j] = s[j - 1] - 64;
    }
  }
  for (int i = 1; i <= m; i++) read(a[i]);
  for (int i = 1; i <= m; i++) {
    memset(jud, 0, sizeof(jud));
    for (int j = 1; j <= n; j++) {
      jud[x[j][i]]++;
    }
    maxx = 0;
    for (int k = 1; k <= 6; k++) {
      maxx = max(maxx, jud[k]);
    }
    ans += a[i] * maxx;
  }
  printf("%d\n", ans);
  return;
}
}  // namespace Sakii
int main() {
  Sakii::main();
  return 0;
}
