#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

// (ティツ。ツ古」ツ?催・ツ?? テ・ツョツケテゥツ?? テ」ツつウテ」ツつケテ」ツδ? テゥツ??ィツセツコ)
struct edge{ int to,cap,cost,rev; };

int V; // TODO:initialize
const int MAX_V = 444; // TODO:initialize
const int INF = 19191919; // TODO:initialize
vector<edge> G[MAX_V];
int h[MAX_V]; // テ」ツδ敕」ツδ?」ツδウテ」ツつキテ」ツδ」テ」ツδォ
int dist[MAX_V];
int prevv[MAX_V], preve[MAX_V]; // テァツ崢エテ・ツ可催」ツ?ョテゥツ?づァツつケテ」ツ?ィティツセツコ

void add_edge(int from, int to, int cap, int cost){
    G[from].pb({to,cap,cost,(int)G[to].size()});
    G[to].pb({from,0,-cost,(int)G[from].size()-1});
}

// sテ」ツ?凝」ツつ液テ」ツ?クテ」ツ?ョテヲツオツ?ゥツ?叔テ」ツ?ョテヲツ慊?・ツーツ湘ィツイツサテァツ板ィテヲツオツ?テ、ツクツ催・ツ渉ッティツδステ」ツ?ェテ」ツつ?1)
int min_cost_flow(int s, int t, int f, bool neg = false){
    int res = 0;
    fill(h,h+V,0);
    while(f>0){
        priority_queue<pi,vector<pi>,greater<pi>> pq;
        fill(dist,dist+V,INF);
        dist[s]=0;
        if(neg)
        {
            // bellman-fordテ」ツ?ァhテ」ツつ津ヲツ崢エテヲツ鳴ー
            neg = false;
            bool update;
            do{
                update = false;
                rep(v,V){
                    if(dist[v] == INF) continue;
                    rep(i,G[v].size()){
                        edge &e = G[v][i];
                        if(e.cap>0 && dist[e.to]>dist[v]+e.cost){
                            dist[e.to]=dist[v]+e.cost;
                            prevv[e.to] = v;
                            preve[e.to] = i;
                            update = true;
                        }
                    }
                }
            }while(update);
        }
        else
        {
            // dijkstraテ」ツ?ァhテ」ツつ津ヲツ崢エテヲツ鳴ー
            pq.push(pi(0,s));
            while(!pq.empty()){
                pi p = pq.top();
                pq.pop();
                int v = p.se;
                if(p.fi>dist[v]) continue;
                rep(i,G[v].size()){
                    edge &e = G[v][i];
                    if(e.cap>0 && dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
                        dist[e.to] = dist[v]+e.cost+h[v]-h[e.to];
                        prevv[e.to] = v;
                        preve[e.to] = i;
                        pq.push(pi(dist[e.to],e.to));
                    }
                }
            }
        }

        // テ」ツ?禿」ツつ古、ツサツ・テ、ツクツ甘ヲツオツ?」ツ?崚」ツ?ェテ」ツ??
        if(dist[t]==INF) return -1;

        rep(v,V) h[v] += dist[v];

        // s-tテゥツ鳴禿」ツ?ョテヲツ慊?ァツ淞ュティツキツッテ」ツ?ォテヲツイツソテ」ツ?」テ」ツ?ヲテァツ崢ョテ、ツクツ?ヲツ敖ッテヲツオツ?」ツ??
        int d=f;
        for(int v=t; v!=s; v=prevv[v]) d = min(d,G[prevv[v]][preve[v]].cap);
        f -= d;
        res += d*h[t];

        for(int v=t; v!=s; v=prevv[v]){
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    return res;
}

int main()
{
    int A,B,K;
    cin >>A >>B >>K;

    V = A+B+2;

    vector<string> a(A),b(B);
    rep(i,A) cin >>a[i];
    rep(i,B) cin >>b[i];

    int S = A+B, T = S+1;
    rep(i,A) add_edge(S,i,1,0);
    rep(i,B) add_edge(A+i,T,1,0);

    rep(i,A)rep(j,B)
    {
        int cost = 0;
        cost += a[i][j]-'0';
        cost += b[j][i]-'0';
        add_edge(i,A+j,1,cost);
    }

    int total = 0;
    int ans = 0;
    while(1)
    {
        int F = min_cost_flow(S,T,1);
        if(F==-1) break;

        total += F;
        if(total>K) break;
        ++ans;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4796