#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;
}