#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ppi pair<int,pair<int,int>>
//#define int int64_t
using namespace std;
// /\_/\
// (= ._.)
// / > \>
// encouraging cat
const int INF = 10000000000000000;
//const int mod = 1000000007;
const int mod = 998244353;
const int MAXN = 200005;
//ifstream fin('xor.in');
//ofstream fout('xor.out');
signed main()
{
int n,m,x,y;
cin >> n >> m >> x >> y;
vector<string> combo(n);
vector<int> count(n,0);
for (int i = 0;i < n;i++)
{
cin >> combo[i];
for (int j = 0;j < m;j++)
{
if (combo[i][j] == '1')
{
count[i]++;
}
}
}
int global_res = 0;
for (int b = 0;b < pow(2,n);b++)
{
int nbset = 0;
int total_combo = 0;
vector<int> cnt(m,0);
for (int i = 0;i < n;i++)
{
if (b & (1 << i))
{
nbset++;
total_combo += count[i];
}
}
int res = total_combo -(nbset * x) - (m * y);
global_res = max(res, global_res);
}
cout << global_res << '\n';
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CgojZGVmaW5lIGFsbChhKSBhLmJlZ2luKCksIGEuZW5kKCkKI2RlZmluZSBmYXN0IGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpO2Npbi50aWUoTlVMTCk7Y291dC50aWUoTlVMTCk7CiNkZWZpbmUgcGIgcHVzaF9iYWNrCiNkZWZpbmUgcHBpIHBhaXI8aW50LHBhaXI8aW50LGludD4+Ci8vI2RlZmluZSBpbnQgaW50NjRfdAoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKLy8gICAgL1xfL1wKLy8gICAoPSAuXy4pCi8vICAgLyA+ICBcPgovLyBlbmNvdXJhZ2luZyBjYXQKY29uc3QgaW50IElORiA9IDEwMDAwMDAwMDAwMDAwMDAwOwovL2NvbnN0IGludCBtb2QgPSAxMDAwMDAwMDA3Owpjb25zdCBpbnQgbW9kID0gOTk4MjQ0MzUzOwpjb25zdCBpbnQgTUFYTiA9IDIwMDAwNTsKLy9pZnN0cmVhbSBmaW4oJ3hvci5pbicpOwovL29mc3RyZWFtIGZvdXQoJ3hvci5vdXQnKTsKCnNpZ25lZCBtYWluKCkKewogICAgaW50IG4sbSx4LHk7CiAgICBjaW4gPj4gbiA+PiBtID4+IHggPj4geTsKICAgIHZlY3RvcjxzdHJpbmc+IGNvbWJvKG4pOwogICAgdmVjdG9yPGludD4gY291bnQobiwwKTsKICAgIGZvciAoaW50IGkgPSAwO2kgPCBuO2krKykKICAgIHsKICAgICAgICBjaW4gPj4gY29tYm9baV07CiAgICAgICAgZm9yIChpbnQgaiA9IDA7aiA8IG07aisrKQogICAgICAgIHsKICAgICAgICAgICAgaWYgKGNvbWJvW2ldW2pdID09ICcxJykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgY291bnRbaV0rKzsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGludCBnbG9iYWxfcmVzID0gMDsKICAgIGZvciAoaW50IGIgPSAwO2IgPCBwb3coMixuKTtiKyspCiAgICB7CiAgICAgICAgaW50IG5ic2V0ID0gMDsKICAgICAgICBpbnQgdG90YWxfY29tYm8gPSAwOwogICAgICAgIHZlY3RvcjxpbnQ+IGNudChtLDApOwogICAgICAgIGZvciAoaW50IGkgPSAwO2kgPCBuO2krKykKICAgICAgICB7CiAgICAgICAgICAgIGlmIChiICYgKDEgPDwgaSkpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIG5ic2V0Kys7CiAgICAgICAgICAgICAgICB0b3RhbF9jb21ibyArPSBjb3VudFtpXTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpbnQgcmVzID0gdG90YWxfY29tYm8gLShuYnNldCAqIHgpIC0gKG0gKiB5KTsKICAgICAgICBnbG9iYWxfcmVzID0gbWF4KHJlcywgZ2xvYmFsX3Jlcyk7CiAgICB9CiAgICBjb3V0IDw8IGdsb2JhbF9yZXMgPDwgJ1xuJzsKICAgIHJldHVybiAwOwp9