#include <iostream>

using namespace std;

bool took[1005][1005];
int m, n, k;

void ShipArea()
{
    for(int i=1;i < m;i++)
    {
        for(int j=1;j < n;j++)
        {
            if(took[i][j] && !((took[i-1][j]) || (took[i][j-1])))
            {
                if(took[i][j+1])
                {
                    took[i-1][j-1] = took[i][j-1] = took[i+1][j-1] = true;
                    for(int k=j;;k++)
                    {
                        took[i-1][k] = took[i+1][k] = true;
                        if(!took[i][k])
                        {
                            took[i][k] = true;
                            break;
                        }
                    }
                }
                else if(took[i+1][j])
                {
                    took[i-1][j-1] = took[i-1][j] = took[i-1][j+1] = true;
                    for(int k=i;;k++)
                    {
                        took[k][j-1] = took[k][j+1] = true;
                        if(!took[k][j])
                        {
                            took[k][j] = true;
                            break;
                        }
                    }
                }
            }
        }
    }
}

int vert()
{
    int br=0, i, b, d;
    for(int j=1;j < n;j++)
    {
        i = 1;
        while(i < m)
        {
            while((took[i][j]) && (i < m))i++;
            b = i;
            while(!(took[i][j]) && (i < m))i++;
            d = i-b;
            if(d >= k)br += d - k + 1;
        }
    }
    return br;
}

int hor()
{
    int br=0, j, b, d;
    for(int i=1;i < m;i++)
    {
        j = 1;
        while(j < n)
        {
            while((took[i][j]) && (j < n))j++;
            b = j;
            while(!(took[i][j]) && (j < n))j++;
            d = j-b;
            if(d >= k)br += d - k + 1;
        }
    }
    return br;
}

void Input()
{
    cin >> m >> n;
    cin >> k;
    m++;
    n++;
    for(int i=1;i < m;i++)
    {
        for(int j=1;j < n;j++)
        {
            cin >> took[i][j];
        }
    }
}

int main()
{
    Input();
    ShipArea();
    
    cout << hor() << " " << vert() << endl;
    
    return 0;
}