/*\
TASK: TRE
LANG: C++
*/
#include <iostream>
using namespace std;
int N, K, L, D;
int arr[10002];
bool sort_by_pos = true;
class treasure
{   public:
    int earn;
    int pos;
    int depth;
    double coef;
    bool active;
    bool operator<(treasure const &a) const
    {
        if (sort_by_pos)
         return (*this).pos < a.pos;
        return (*this).coef > a.coef;
    };
}tr[1001];

int main()
{
    cin >> N >> K >> L >> D;
    int i, j, x, cnt = 0;
    for (i=1;i <= D;i++)
     for (j=1;j <= L;j++)
     {
         cin >> x;
         arr[j] += x;
         if (x > 0)
         {
            tr[cnt].earn = arr[j];
            tr[cnt].depth = i;
            tr[cnt].pos = j;
            tr[cnt].active = true;
            tr[cnt++].coef = (double)arr[j] / (double)i;
         }
     }
    
    sort(tr, tr + N);
    for (i=1;i < N;i++)
     if (tr[i-1].pos == tr[i].pos)
      if (tr[i-1].earn > tr[i].earn)
       tr[i].active = false;
      else tr[i-1].active = false;
    
    sort_by_pos = false;
    sort(tr, tr + N);
    
    int total_earn = 0, total_time = 0;
    for (i=0;i < N;i++)
    {
        if (!tr[i].active) continue;
        total_earn += tr[i].earn;
        total_time += tr[i].depth;
        if (total_time > K)
        {
            cout << (total_earn - tr[i].earn) << endl;
            //system("pause");
            return 0;
        }
    }
    cout << total_earn << endl;
    
    //for (i=0;i < N;i++)
    // cout << tr[i].earn << " " << tr[i].depth << " " << tr[i].coef << " " << tr[i].active << endl;
    
    //system("pause");
    return 0;
}
