/* GCC */
#define author FIvanO
#include <iostream>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <string>
#include <map>
#include <vector>
const int Max=1000;

using namespace std;

int col[Max+10][Max+10];
int col1[Max+10][Max+10];
map <int,int> a;
//int b[Max+10];
//int VVP[Max+10];
int main()
{
ios_base::sync_with_stdio(0);
freopen("display.in","r",stdin);
freopen("display.out","w",stdout);
int n,m,n1,m1,k,c,f,k0;
bool flag=true;
cin>>n>>m>>n1>>m1>>k;
for (int i=0; i<n; i++)
for (int j=0; j<m; j++) { cin>>col[i][j]; col1[i][j]=col[i][j]; a[col[i][j]]++; }
if (a[0]==n*m) { cout<<0<<endl; return 0; }

int kol=(n-n1)*(m-m1);
for (int k=0; k<kol; k++)
    for (int i=0; i<(n-n1); i++)
        for (int j=0; j<(m-m1); j++)
        {
            k0=a[0];
            a[col[i][j]]--;
            col1[i][j]++;
            a[col[i][j]]++;
            if (col1[i][j]==k) { a[col1[i][j]]--; col1[i][j]=0; a[0]++; }
        }

if (a[0]==m*n) cout<<kol<<endl; else cout<<"impossible"<<endl;
//if (n1==n && m1==m && !flag) { cout<<"impossible"<<endl; return 0; }
//if (n1==n && m1==m && flag) { cout<<k-c<<endl; return 0; }



return 0;
}
