#include <bits/stdc++.h>
using namespace std;
const double PI = 2 * asin(1.0);
const int INF = 1000000000;
const double EPS = 1e-10;
inline int cmp(double x, double y = 0, double tol = EPS) {
  return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
inline long long gcd(long long n1, long long n2) {
  return n2 == 0 ? abs(n1) : gcd(n2, n1 % n2);
}
inline long long lcm(long long n1, long long n2) {
  return n1 == 0 || n2 == 0 ? 0 : abs(n1 * (n2 / gcd(n1, n2)));
}
const int N = 110;
int cap[N][N], cost[N][N], fnet[N][N];
int adj[N][N], deg[N];
int par[N], d[N];
bool vis[N];
int pi[N];
int Pot(int u, int v) { return d[u] + pi[u] - pi[v]; }
bool dijkstra(int s, int t, int n) {
  for (int i = 0; i < n; ++i) {
    d[i] = INF / 2;
    par[i] = -1;
    vis[i] = false;
  }
  d[s] = 0;
  while (1) {
    int u = -1, best = INF / 2;
    for (int i = 0; i < n; ++i)
      if (d[i] < best && !vis[i]) {
        best = d[i];
        u = i;
      }
    if (u == -1) break;
    vis[u] = true;
    for (int i = 0; i < deg[u]; ++i) {
      int v = adj[u][i];
      if (vis[v]) continue;
      if (fnet[v][u] > 0 && d[v] > Pot(u, v) - cost[v][u]) {
        d[v] = Pot(u, v) - cost[v][u];
        par[v] = u;
      }
      if (fnet[u][v] < cap[u][v] && d[v] > Pot(u, v) + cost[u][v]) {
        d[v] = Pot(u, v) + cost[u][v];
        par[v] = u;
      }
    }
  }
  for (int i = 0; i < n; ++i)
    if (pi[i] < INF / 2) pi[i] += d[i];
  return vis[t];
}
pair<long long, long long> minCostMaxFlow(int s, int t, int n,
                                          long long maxCost) {
  memset(deg, 0, sizeof(deg));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      if (cap[i][j] || cap[j][i]) adj[i][deg[i]++] = j;
  memset(fnet, 0, sizeof(fnet));
  memset(pi, 0, sizeof(pi));
  long long flow = 0, fcost = 0;
  while (dijkstra(s, t, n)) {
    long long bot = INF;
    for (int v = t; v != s; v = par[v]) {
      int u = par[v];
      bot = min(int(bot), (fnet[v][u] ? fnet[v][u] : cap[u][v] - fnet[u][v]));
    }
    long long cumCost = 0;
    for (int v = t; v != s; v = par[v]) {
      int u = par[v];
      if (fnet[v][u]) {
        fnet[v][u] -= bot;
        cumCost -= cost[v][u];
      } else {
        fnet[u][v] += bot;
        cumCost += cost[u][v];
      }
    }
    if (fcost + bot * cumCost > maxCost) {
      bot = (maxCost - fcost) / cumCost;
      flow += bot;
      fcost += bot * cumCost;
      return pair<int, int>(flow, fcost);
    }
    flow += bot;
    fcost += bot * cumCost;
  }
  return pair<int, int>(flow, fcost);
}
int main() {
  int n, k;
  cin >> n >> k;
  memset(cap, 0, sizeof(cap));
  memset(cost, 0, sizeof(cost));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int x;
      cin >> x;
      if (x == 0) continue;
      cap[2 * i][2 * j] = x;
      cost[2 * i][2 * j] = 0;
      cap[2 * i][2 * j + 1] = INF / 3;
      cost[2 * i][2 * j + 1] = 1;
      cost[2 * j + 1][2 * i] = 1;
    }
    cap[2 * i + 1][2 * i] = INF / 3;
    cost[2 * i + 1][2 * i] = 0;
  }
  pair<int, int> res = minCostMaxFlow(0, 2 * (n - 1), 2 * n, k);
  cout << res.first << endl;
  return 0;
}

### Prompt

Generate a CPP solution to the following problem:

A little boy Petya dreams of growing up and becoming the Head Berland Plumber. He is thinking of the problems he will have to solve in the future. Unfortunately, Petya is too inexperienced, so you are about to solve one of such problems for Petya, the one he's the most interested in.

The Berland capital has n water tanks numbered from 1 to n. These tanks are connected by unidirectional pipes in some manner. Any pair of water tanks is connected by at most one pipe in each direction. Each pipe has a strictly positive integer width. Width determines the number of liters of water per a unit of time this pipe can transport. The water goes to the city from the main water tank (its number is 1). The water must go through some pipe path and get to the sewer tank with cleaning system (its number is n). 

Petya wants to increase the width of some subset of pipes by at most k units in total so that the width of each pipe remains integer. Help him determine the maximum amount of water that can be transmitted per a unit of time from the main tank to the sewer tank after such operation is completed.

Input

The first line contains two space-separated integers n and k (2 ≤ n ≤ 50, 0 ≤ k ≤ 1000). Then follow n lines, each line contains n integers separated by single spaces. The i + 1-th row and j-th column contain number cij — the width of the pipe that goes from tank i to tank j (0 ≤ cij ≤ 106, cii = 0). If cij = 0, then there is no pipe from tank i to tank j.

Output

Print a single integer — the maximum amount of water that can be transmitted from the main tank to the sewer tank per a unit of time.

Examples

Input

5 7
0 1 0 2 0
0 0 4 10 0
0 0 0 0 5
0 0 0 0 10
0 0 0 0 0


Output

10


Input

5 10
0 1 0 0 0
0 0 2 0 0
0 0 0 3 0
0 0 0 0 4
100 0 0 0 0


Output

5

Note

In the first test Petya can increase width of the pipe that goes from the 1st to the 2nd water tank by 7 units.

In the second test Petya can increase width of the pipe that goes from the 1st to the 2nd water tank by 4 units, from the 2nd to the 3rd water tank by 3 units, from the 3rd to the 4th water tank by 2 units and from the 4th to 5th water tank by 1 unit.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const double PI = 2 * asin(1.0);
const int INF = 1000000000;
const double EPS = 1e-10;
inline int cmp(double x, double y = 0, double tol = EPS) {
  return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
inline long long gcd(long long n1, long long n2) {
  return n2 == 0 ? abs(n1) : gcd(n2, n1 % n2);
}
inline long long lcm(long long n1, long long n2) {
  return n1 == 0 || n2 == 0 ? 0 : abs(n1 * (n2 / gcd(n1, n2)));
}
const int N = 110;
int cap[N][N], cost[N][N], fnet[N][N];
int adj[N][N], deg[N];
int par[N], d[N];
bool vis[N];
int pi[N];
int Pot(int u, int v) { return d[u] + pi[u] - pi[v]; }
bool dijkstra(int s, int t, int n) {
  for (int i = 0; i < n; ++i) {
    d[i] = INF / 2;
    par[i] = -1;
    vis[i] = false;
  }
  d[s] = 0;
  while (1) {
    int u = -1, best = INF / 2;
    for (int i = 0; i < n; ++i)
      if (d[i] < best && !vis[i]) {
        best = d[i];
        u = i;
      }
    if (u == -1) break;
    vis[u] = true;
    for (int i = 0; i < deg[u]; ++i) {
      int v = adj[u][i];
      if (vis[v]) continue;
      if (fnet[v][u] > 0 && d[v] > Pot(u, v) - cost[v][u]) {
        d[v] = Pot(u, v) - cost[v][u];
        par[v] = u;
      }
      if (fnet[u][v] < cap[u][v] && d[v] > Pot(u, v) + cost[u][v]) {
        d[v] = Pot(u, v) + cost[u][v];
        par[v] = u;
      }
    }
  }
  for (int i = 0; i < n; ++i)
    if (pi[i] < INF / 2) pi[i] += d[i];
  return vis[t];
}
pair<long long, long long> minCostMaxFlow(int s, int t, int n,
                                          long long maxCost) {
  memset(deg, 0, sizeof(deg));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      if (cap[i][j] || cap[j][i]) adj[i][deg[i]++] = j;
  memset(fnet, 0, sizeof(fnet));
  memset(pi, 0, sizeof(pi));
  long long flow = 0, fcost = 0;
  while (dijkstra(s, t, n)) {
    long long bot = INF;
    for (int v = t; v != s; v = par[v]) {
      int u = par[v];
      bot = min(int(bot), (fnet[v][u] ? fnet[v][u] : cap[u][v] - fnet[u][v]));
    }
    long long cumCost = 0;
    for (int v = t; v != s; v = par[v]) {
      int u = par[v];
      if (fnet[v][u]) {
        fnet[v][u] -= bot;
        cumCost -= cost[v][u];
      } else {
        fnet[u][v] += bot;
        cumCost += cost[u][v];
      }
    }
    if (fcost + bot * cumCost > maxCost) {
      bot = (maxCost - fcost) / cumCost;
      flow += bot;
      fcost += bot * cumCost;
      return pair<int, int>(flow, fcost);
    }
    flow += bot;
    fcost += bot * cumCost;
  }
  return pair<int, int>(flow, fcost);
}
int main() {
  int n, k;
  cin >> n >> k;
  memset(cap, 0, sizeof(cap));
  memset(cost, 0, sizeof(cost));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int x;
      cin >> x;
      if (x == 0) continue;
      cap[2 * i][2 * j] = x;
      cost[2 * i][2 * j] = 0;
      cap[2 * i][2 * j + 1] = INF / 3;
      cost[2 * i][2 * j + 1] = 1;
      cost[2 * j + 1][2 * i] = 1;
    }
    cap[2 * i + 1][2 * i] = INF / 3;
    cost[2 * i + 1][2 * i] = 0;
  }
  pair<int, int> res = minCostMaxFlow(0, 2 * (n - 1), 2 * n, k);
  cout << res.first << endl;
  return 0;
}

```