/**

 * Intermediate 5

 * Ray Chinese School

 * @author Brice Wang

 */

package test3;

 

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Arrays;

import java.util.Scanner;

 

public class Brice {

 

    public static void markSpots(int x , int y , int range) {

        board[x][y] = false;

        int[][] surround = {{1 , 0} , {1 , 1} , {0 , 1} , {-1 , 1} , {-1 , 0} , {-1 , -1} ,

                {0 , -1} , {1 , -1}};

        for (int i = 0 ; i < surround.length ; i++) {

            moveQueen(x , y , surround[i][0] , surround[i][1] , range);

        }

    }

 

    public static void moveQueen(int x , int y , int dx , int dy , int moves) {

        x += dx;

        y += dy;

       

        if ((x < 0 || x > 7) || (y < 0 || y > 7) || moves == 0) {

            return;

        }

       

        board[x][y] = false;

        moveQueen(x , y , dx , dy , moves - 1);

    }

 

    public static void main(String[] args) {

        Scanner input;

        try {

            input = new Scanner(new File("ChessQueens.in.txt"));

        } catch (FileNotFoundException ex) {

            System.out.println("File not found.");

            return;

        }

       

        board = new boolean[8][8];

       

        for (int i = 0 ; i < 5 ; i++) {

            for (int aaa = 0 ; aaa < 8 ; aaa++) {

                Arrays.fill(board[aaa] , true); //resets board

            }

           

            String temp = input.nextLine();

            Scanner sc = new Scanner(temp);

           

            int x1 = sc.nextInt() - 1;

            int y1 = sc.nextInt() - 1;

            int x2 = sc.nextInt() - 1;

            int y2 = sc.nextInt() - 1;

            int range = sc.nextInt();

           

            markSpots(x1 , y1 , range);

            markSpots(x2 , y2 , range);

           

            int count = 0;

            for (boolean[] m : board) {

                for (boolean n : m) {

                    if (n) {

                        count++;

                    }

                }

            }

            System.out.println(count);

        }

    }

   

    static boolean[][] board;

}