#include <bits/stdc++.h>   using namespace std;   long long int power(long long int x, long long int y, long long int p) {     long long int r = 1;     x = x % p;     while (y) {       if (y & 1) r = r * x % p;       y = y >> 1;       x = x * x % p;     }     return r;   }   const long long int N = 5005;   long long int n, k;   struct edge {     long long int to, flow, cap, cost, rev;   };   struct MinCostMaxFlow {     long long int nodes;     vector<long long int> prio, curflow, prevedge, prevnode, q, pot;     vector<bool> inqueue;     vector<vector<edge> > graph;     MinCostMaxFlow() {}     MinCostMaxFlow(long long int n)         : nodes(n),           prio(n, 0),           curflow(n, 0),           prevedge(n, 0),           prevnode(n, 0),           q(n, 0),           pot(n, 0),           inqueue(n, 0),           graph(n) {}     void addEdge(long long int source, long long int to, long long int capacity,                  long long int cost) {       edge a = {to, 0, capacity, cost, (long long int)graph[to].size()};       edge b = {source, 0, 0, -cost, (long long int)graph[source].size()};       graph[source].push_back(a);       graph[to].push_back(b);     }     void bellman_ford(long long int source, vector<long long int> &dist) {       fill(dist.begin(), dist.end(), INT_MAX);       dist[source] = 0;       long long int qt = 0;       q[qt++] = source;       for (long long int qh = 0; (qh - qt) % nodes != 0; qh++) {         long long int u = q[qh % nodes];         inqueue[u] = false;         for (auto &e : graph[u]) {           if (e.flow >= e.cap) continue;           long long int v = e.to;           long long int newDist = dist[u] + e.cost;           if (dist[v] > newDist) {             dist[v] = newDist;             if (!inqueue[v]) {               inqueue[v] = true;               q[qt++ % nodes] = v;             }           }         }       }     }     pair<long long int, long long int> minCostFlow(long long int source,                                                    long long int dest,                                                    long long int maxflow) {       bellman_ford(source, pot);       long long int flow = 0;       long long int flow_cost = 0;       while (flow < maxflow) {         priority_queue<pair<long long int, long long int>,                        vector<pair<long long int, long long int> >,                        greater<pair<long long int, long long int> > >             q;         q.push({0, source});         fill(prio.begin(), prio.end(), INT_MAX);         prio[source] = 0;         curflow[source] = INT_MAX;         while (!q.empty()) {           long long int d = q.top().first;           long long int u = q.top().second;           q.pop();           if (d != prio[u]) continue;           for (long long int i = 0; i < graph[u].size(); i++) {             edge &e = graph[u][i];             long long int v = e.to;             if (e.flow >= e.cap) continue;             long long int newPrio = prio[u] + e.cost + pot[u] - pot[v];             if (prio[v] > newPrio) {               prio[v] = newPrio;               q.push({newPrio, v});               prevnode[v] = u;               prevedge[v] = i;               curflow[v] = min(curflow[u], e.cap - e.flow);             }           }         }         if (prio[dest] == INT_MAX) break;         for (long long int i = 0; i < nodes; i++) pot[i] += prio[i];         long long int df = min(curflow[dest], maxflow - flow);         flow += df;         for (long long int v = dest; v != source; v = prevnode[v]) {           edge &e = graph[prevnode[v]][prevedge[v]];           e.flow += df;           graph[v][e.rev].flow -= df;           flow_cost += df * e.cost;         }       }       return {flow, flow_cost};     }   };   long long int a[100][100];   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     for (long long int i = 0; i < n; i++)       for (long long int j = 0; j < n; j++) cin >> a[i + 1][j + 1];     long long int lo = 1, hi = 1e9, ans = 0, mi;     while (lo <= hi) {       MinCostMaxFlow mcmf(n + 1);       mi = (lo + hi) / 2;       for (long long int i = 1; i <= n; i++)         for (long long int j = 1; j <= n; j++)           if (a[i][j] > 0)             mcmf.addEdge(i, j, a[i][j], 0), mcmf.addEdge(i, j, 1e5, 1);       pair<long long int, long long int> xx = mcmf.minCostFlow(1, n, mi);       if (xx.second <= k)         ans = max(ans, xx.first), lo = mi + 1;       else         hi = mi - 1;     }     cout << ans <<   n ;   }