// Arup Guha
// 8/27/2022
// Alternate Solution to 2022 UCF Locals Qualifying Problem: RCV Simplification

import java.util.*;

public class maze_arup {

	// The weird order of directions is based on the energy points for panda. Direction i takes i+1 energy points for movement.
	final public static int[] DX = {-1,-1,-1,0,1,1,1,0};
	final public static int[] DY = {-1,0,1,1,1,0,-1,-1};
	
	public static int r;
	public static int c;
	public static int[][] grid;
	public static int maxE;
	
	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		r = stdin.nextInt();
		c = stdin.nextInt();
		int sX = stdin.nextInt()-1;
		int sY = stdin.nextInt()-1;
		maxE = stdin.nextInt();
		
		// Read in grid.
		grid = new int[r][c];
		for (int i=0; i<r; i++)
			for (int j=0; j<c; j++)
				grid[i][j] = stdin.nextInt();
	
		// Solve it!
		System.out.println(dijkstras(sX,sY));
	}
	
	// Runs Dijkstra's from (sX, sY) and returns the max box value we can obtain under the restrictions.
	public static int dijkstras(int sX, int sY) {
	
		// My distance array.
		int[][] dist = new int[r][c];
		boolean[][] done = new boolean[r][c];
		for (int i=0; i<r; i++) Arrays.fill(dist[i], maxE+1);
		dist[sX][sY] = 0;
		
		// Priority Queue...
		PriorityQueue<estimate> pq = new PriorityQueue<estimate>();
		pq.offer(new estimate(sX, sY, 0));
		int res = 0;
		
		// Run Dijkstra's.
		while (pq.size() > 0) {
		
			// Get the next estimate.
			estimate cur = pq.poll();
			
			// We got here before.
			if (done[cur.x][cur.y]) continue;
			
			// Mark this as done.
			done[cur.x][cur.y] = true;			
			
			// No need to continue;
			if (cur.cost > maxE) break;
			
			// Annoying...if this is a treasure box, we stop.
			if (grid[cur.x][cur.y] != 0) {
				res = Math.max(res, grid[cur.x][cur.y]);
				continue;
			}
			
			// Try all 8 directions of movement.
			for (int i=0; i<DX.length; i++) {
				int nX = cur.x + DX[i];
				int nY = cur.y + DY[i];
				
				if (!inbounds(nX, nY)) continue;
				
				// Cost going this way.
				int nC = cur.cost+i+1;
				
				// Can't help.
				if (nC >= dist[nX][nY]) continue;
				
				// Add to our estimates.
				dist[nX][nY] = nC;
				pq.offer(new estimate(nX, nY, nC));
			}
		}
		
		// Ta da!
		return res;
	}
	
	// Returns true iff (x,y) is in the grid.
	public static boolean inbounds(int x, int y) {
		return x >= 0 && x < r && y >= 0 && y < c;
	}

}

// Just so we can run Dijkstra's.
class estimate implements Comparable<estimate> {

	public int x;
	public int y;
	public int cost;
	
	public estimate(int myx, int myy, int mycost) {
		x = myx;
		y = myy;
		cost = mycost;
	}
	
	public int compareTo(estimate other) {
		return cost - other.cost;
	}
}