#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int head[200011], nxt[200011], to[200011], cost[200011], cap[200011];
int dst[55];
int E;
int q[200011], qf, qb;
int pre[200011];
int n, k;
void add(int u, int v, int c) {
  nxt[E] = head[u];
  to[E] = v;
  cap[E] = c;
  head[u] = E++;
  nxt[E] = head[v];
  to[E] = u;
  cap[E] = 0;
  head[v] = E++;
  nxt[E] = head[u];
  to[E] = v;
  cap[E] = 0x3f3f3f3f;
  cost[E] = 1;
  head[u] = E++;
  nxt[E] = head[v];
  to[E] = u;
  cap[E] = 0;
  cost[E] = -1;
  head[v] = E++;
}
int max_flow(int src, int tar) {
  int ans = 0, v, bot, C = 0;
  while (1) {
    qf = qb = 0;
    q[qb++] = src;
    memset(dst, 0x3f, sizeof dst);
    dst[src] = 0;
    while (qb > qf) {
      int u = q[qf++];
      for (int e = head[u]; e != -1; e = nxt[e]) {
        int v = to[e];
        if (dst[v] > dst[u] + cost[e] && cap[e]) {
          dst[v] = dst[u] + cost[e];
          q[qb++] = v;
          pre[v] = e;
        }
      }
    }
    bot = 0x3f3f3f3f;
    if (dst[tar] == 0x3f3f3f3f) return ans;
    for (int t = tar; t != src; t = to[pre[t] ^ 1]) {
      smin(bot, cap[pre[t]]);
    }
    if (1ll * bot * dst[tar] <= k) {
      C += bot * dst[tar];
      k -= bot * dst[tar];
      ans += bot;
    } else
      return (ans + k / dst[tar]);
    for (int t = tar; t != src; t = to[pre[t] ^ 1]) {
      cap[pre[t]] -= bot;
      cap[pre[t] ^ 1] += bot;
    }
  }
}
int main() {
  cin >> n >> k;
  int src = 1, tar = n;
  memset(head, -1, sizeof head);
  for (int i = 1; i <= n; i++) {
    for (int j = 1, u; j <= n; j++) {
      gn(u);
      if (u) add(i, j, u);
    }
  }
  int ans = max_flow(src, tar);
  cout << ans << endl;
  return 0;
}
