import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改public class Main {public static void main(String[] args) {Scanner scan = new Scanner(System.in);//在此输入您的代码...int n = scan.nextInt();int m = scan.nextInt();int[][]map = new int[n+1][m+1];//初始化mapfor (int i = 1; i < n+1; i++) {for (int j = 1; j < m+1; j++) {map[i][j] = 0;}}int t = scan.nextInt();int ans = t;Queue<Integer>queI = new LinkedList<>();Queue<Integer>queJ = new LinkedList<>();for (int i = 0; i < t; i++) {int I = scan.nextInt();int j = scan.nextInt();map[I][j] = 1;queI.offer(I);queJ.offer(j);} int k = scan.nextInt();while (!queI.isEmpty()&&k-->0) {int length = queI.size();for (int i = 0; i < length; i++) {int cur_I = queI.poll(); int cur_J =queJ.poll();int[]dx = {0,1,0,-1};int[]dy = {1,0,-1,0};for (int j = 0; j < dy.length; j++) {int x = cur_I+dx[j];int y = cur_J+dy[j];if (x<1||y<1||x>n||y>m||map[x][y]==1) {continue;}else {ans++;map[x][y] = 1;queI.offer(x);queJ.offer(y);}}}}System.out.println(ans);scan.close();}
}
class Solution {public int maxAreaOfIsland(int[][] grid) {int ans = 0;for (int i = 0; i < grid.length; i++) {for (int j = 0; j < grid[0].length; j++) {int cur = 0;Queue<Integer> queueI = new LinkedList<>();Queue<Integer> queueJ = new LinkedList<>();queueI.offer(i);queueJ.offer(j);while(!queueI.isEmpty()){int cur_i = queueI.poll(),cur_j = queueJ.poll();if (cur_i<0||cur_j<0||cur_i==grid.length||cur_j==grid[0].length||grid[cur_i][cur_j]!=1){continue;}++cur;grid[cur_i][cur_j] = 0;int[] dx = {0,1,0,-1};int[] dy = {1,0,-1,0};for (int i1 = 0; i1 < 4; i1++) {queueI.offer(cur_i+dx[i1]);queueJ.offer(cur_j+dy[i1]);}}ans = Math.max(cur,ans);}}return ans;}
}