#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
using namespace std;
int max_strength(int n, int m, int x, int y, vector<string>& mat) {
int max_strength = 0;
for (int rm = 0; rm < (1 << n); ++rm) {
for (int bm = 0; bm < (1 << m); ++bm) {
int r_count = __builtin_popcount(rm);
int b_count = __builtin_popcount(bm);
int w = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
if ((rm & (1 << i)) && (bm & (1 << j)) && mat[i][j] == '1') {
w++;
}
}
}
int strength = w - x * r_count - y * b_count;
max_strength = max(max_strength, strength);
}
}
return max_strength;
}
int main() {
int n, m, x, y;
cin >> n >> m >> x >> y;
vector<string> mat(n);
for (int i = 0; i < n; ++i) {
cin >> mat[i];
}
cout << max_strength(n, m, x, y, mat) << endl;
return 0;
}