import sys

class Picture:
    def __init__(self, picture_size):
        self.picture_size = picture_size
        self.all_cells = []
        self.empty_cells = []
        self.non_empty_cells = []
        # Empty matrix
        self.graph = [[0 for i in range(picture_size)] for j in range(picture_size)]
        self.suns = []
        self.houses = []
        self.chupacebras = []
        self.left_slope = []
        self.right_slope = []
        self.peaks = []
        self.birds_not_drakes = []
        self.drakes = []
        self.grills = []

    def get_graph(self):
        return self.graph

    def get_picture_size(self):
        return self.picture_size

    def correct_len(self):
        self.picture_size -= 1

    def add_element(self, cell):
        x, y = cell.get_pos()
        self.graph[x][y] = cell
        self.all_cells.append(cell)

        if cell is Sun:
            self.suns.append(cell)
        elif cell is House:
            self.houses.append(cell)
        elif cell is Chupacabra:
            self.chupacebras.append(cell)
        elif cell is Slope and cell.get_is_left() == True:
            self.left_slope.append(cell)
        elif cell is Slope and cell.get_is_left() == False:
            self.right_slope.append(cell)
        elif cell is Peaks:
            self.peaks.append(cell)
        elif cell is Bird and cell is not Drake:
            self.birds_not_drakes.append(cell)
        elif cell is Grill:
            self.grills.append(cell)
        elif cell is Drake:
            self.drakes.append(cell)

        if cell is Non_Empty_Symbol:
            self.non_empty_cells.append(cell)
        elif cell is Empty_Symbol:
            self.empty_cells.append(cell)

    def calculate_3x3(self):
        square_x_index = 0
        square_y_index = 0
        all_blocks = []
        unique_count = 0
        for current_square in self.picture_size:
            current_block = []
            for x in range(square_x_index, square_x_index + 3):
                for y in range(square_y_index, square_y_index + 3):
                    current_block.append(self.graph[x][y])
                square_y_index += 1

            if current_block not in all_blocks:
                unique_count += 1

            all_blocks.append(current_block)
            square_x_index += 1

        return 1 * unique_count

    def calculate_biggest_bird(self):
        all_birds = self.birds_not_drakes + self.drakes
        max_width = 0
        for bird in all_birds:
            tmp_width = 0
            bird_x = bird.get_pos()[0]
            bird_y = bird.get_pos()[1]

            # check up-down
            for row in range(0, self.picture_size):
                if all_birds[row][bird_y] is Bird:
                    tmp_width += 1
                else:
                    if tmp_width > max_width:
                        max_width = tmp_width

            tmp_width = 0
            # check left-right
            for column in range(0, self.picture_size):
                if all_birds[bird_x][column] is Bird:
                    tmp_width += 1
                else:
                    if tmp_width > max_width:
                        max_width = tmp_width

        return 500 * max_width

    def calculate_flock_perimeter(self):
        total_flock_value = 0

        all_birds = self.birds_not_drakes + self.drakes

        flocks = []
        for bird in all_birds:
            flock = bird.find_dfs_cells(type(Bird))

            if set(flock) in flocks:
                continue

            current_perimeter = 0
            for bird_in_flock in flock:
                bird_x = bird_in_flock.get_pos()[0]
                bird_y = bird_in_flock.get_pos()[1]
                try:
                    cell = self.graph[bird_x + 1][bird_y]
                    if cell is not Bird:
                        current_perimeter += 1
                except IndexError:
                    current_perimeter += 1
                try:
                    cell = self.graph[bird_x - 1][bird_y]
                    if cell is not Bird:
                        current_perimeter += 1
                except IndexError:
                    current_perimeter += 1
                try:
                    cell = self.graph[bird_x][bird_y - 1]
                    if cell is not Bird:
                        current_perimeter += 1
                except IndexError:
                    current_perimeter += 1
                try:
                    cell = self.graph[bird_x][bird_y + 1]
                    if cell is not Bird:
                        current_perimeter += 1
                except IndexError:
                    current_perimeter += 1

            total_flock_value += 60 * current_perimeter
            flocks.append(set(flock))

        return total_flock_value

    def calc_min_freq(self):
        arrays = [self.suns, self.houses, self.chupacebras, self.left_slope,
                  self.right_slope, self.peaks, self.birds_not_drakes, self.drakes, self.grills]
        min_array = []
        min_freq = len(arrays[0])

        for array in arrays:
            arr_len = len(array)
            if arr_len < min_freq:
                min_array = array
                min_freq = arr_len

        for arr_elem in min_array:
            arr_elem.add_to_generate_value(10)

    def all_animals_value(self):
        return 1 * len(self.chupacebras) * len(self.birds_not_drakes) * len(self.drakes)

    def houses_and_grills(self):
        return 3 * min(len(self.houses), len(self.grills))

    def calculate_total_value(self):
        total_value = 0

        # Calculate Min Freq
        self.calc_min_freq()

        # Calculate all cells value
        for cell in self.all_cells:
            total_value += cell.calc_cell_value()

        # Calculate 3x3 blocks
        total_value += self.calculate_3x3()

        # Calculate Biggest bird
        total_value += self.calculate_biggest_bird()

        # Calculate Flock perimeter
        total_value += self.calculate_flock_perimeter()

        # Calculate Animals 2
        total_value += self.all_animals_value()

        # Calculate Houses and grills
        total_value += self.houses_and_grills()

        return total_value


class Symbol:
    def __init__(self, position, picture_size):
        self.x = position[0]
        self.y = position[1]
        self.picture_size = picture_size
        self.graph = None
        self.picture = None
        self.adjacent_cells = []
        self.all_adjacent_cells = []
        self.default_generate_value = 0
        self.is_on_border = self.check_is_on_border(picture_size)

    def set_graph(self, graph):
        self.graph = graph

    def set_picture(self, picture):
        self.picture = picture

    def get_pos(self):
        return self.x, self.y

    def check_is_on_border(self, picture_size):
        # Right border
        if self.x + 1 == picture_size:
            return True
        # Left border
        elif self.x + 1 == 1:
            return True
        # Up border
        elif self.y + 1 == picture_size:
            return True
        # Down border
        elif self.y + 1 == 1:
            return True
        else:
            return False

    def get_is_on_border(self):
        return self.is_on_border

    def add_to_generate_value(self, add_value):
        self.default_generate_value += add_value

    # Returns only non-empty
    def get_adjacent_cells(self):
        return self.adjacent_cells

    # Returns even empty symbols
    def get_all_adjacent_cells(self):
        return self.all_adjacent_cells

    def add_adjacent_cell(self, cell):
        if cell is Empty_Symbol:
            self.all_adjacent_cells.append(cell)
        else:
            self.adjacent_cells.append(cell)

    # https://www.educative.io/edpresso/how-to-implement-depth-first-search-in-python
    # returns all non-empty adj cells
    def find_dfs_cells(self, spec_type):
        # Something like DFS search
        visited = []
        return self.dfs(visited, spec_type)

    def dfs(self, visited, spec_type):
        if self not in visited and self is spec_type:
            visited.add(self)
            for neighbour in self.get_adjacent_cells():
                neighbour.dfs(visited)
        return visited

    def get_connection(self, target_cell):
        all_connections = self.find_dfs_cells(type(Symbol))
        connection = []
        for cell in all_connections:
            connection.append(cell)
            if cell == target_cell:
                return connection
        return []

    def is_connected(self, target_cell):
        all_connections = self.find_dfs_cells(type(Symbol))
        if target_cell in all_connections:
            return True
        else:
            return False

    def calc_cell_value(self):
        pass

# https://www.geeksforgeeks.org/maximum-manhattan-distance-between-a-distinct-pair-from-n-coordinates/
def max_manh_distance(A, N):
    # Stores the maximum distance
    maximum = - sys.maxsize

    for i in range(N):
        sum = 0

        for j in range(i + 1, N):
            # Find Manhattan distance
            # using the formula
            # |x1 - x2| + |y1 - y2|
            Sum = (abs(A[i][0] - A[j][0]) +
                   abs(A[i][1] - A[j][1]))

            # Updating the maximum
            maximum = max(maximum, Sum)
    return maximum

class Empty_Symbol(Symbol):

    def __init__(self, position, picture_size):
        super().__init__(position, picture_size)
        # EMPTY FIELDS condition
        self.default_generate_value = 1

    def calc_cell_value(self):
        return self.default_generate_value


class Non_Empty_Symbol(Symbol):

    def __init__(self, position, picture_size):
        super().__init__(position, picture_size)
        self.default_generate_value = 0

    def check_freedom(self):
        if self.is_on_border:
            return True
        all_connections = self.find_dfs_cells(type(Symbol))
        for cell in all_connections:
            if cell.get_is_on_border():
                return True
        return False

    def calc_cell_value(self):
        self.graph = self.picture.get_graph()

        value = self.default_generate_value

        # FREEDOM condition
        if self.check_freedom():
            value += 7

        # IS ILLUMINATED condition
        if self.is_illuminated_by_sun():
            value += 100

        # HOUSE view up 1 condition
        # HOUSE view down 2 condition
        if self is House:
            self.check_view_up()
            self.check_view_down()

        # ANIMALS 1 condition
        if self is Animal:
            self.animals_first_condition()

        # Drake / grill condition
        if self is Drake and self.is_drake_grill(type(Grill)):
            value += 500

        # Grill / Drake condition
        if self is Grill and self.is_drake_grill(type(Drake)):
            value += 50

        # Chupacabra
        if self is Chupacabra:
            value += self.calc_chupacabra()

        # Peaks
        if self is Peaks:
            value += self.calc_peaks()

    def calc_peaks(self):
        return 50 * max_manh_distance(self.picture.peaks, len(self.picture.peaks))

    def calc_chupacabra(self):
        # Check knight chess move
        value = 0

        try:
            cell = self.graph[self.x + 2][self.y + 1]
            if cell is Bird:
                value += 200
        except IndexError:
            pass
        try:
            cell = self.graph[self.x + 2][self.y - 1]
            if cell is Bird:
                value += 200
        except IndexError:
            pass

        try:
            cell = self.graph[self.x - 2][self.y + 1]
            if cell is Bird:
                value += 200
        except IndexError:
            pass
        try:
            cell = self.graph[self.x - 2][self.y - 1]
            if cell is Bird:
                value += 200
        except IndexError:
            pass

        try:
            cell = self.graph[self.x + 1][self.y + 2]
            if cell is Bird:
                value += 200
        except IndexError:
            pass
        try:
            cell = self.graph[self.x + 1][self.y - 2]
            if cell is Bird:
                value += 200
        except IndexError:
            pass

        try:
            cell = self.graph[self.x - 1][self.y + 2]
            if cell is Bird:
                value += 200
        except IndexError:
            pass
        try:
            cell = self.graph[self.x - 1][self.y - 2]
            if cell is Bird:
                value += 200
        except IndexError:
            pass

        return value

    def is_illuminated_by_sun(self):

        # Check column up
        for row in range(self.x - 1, -1, -1):
            cell = self.graph[row][self.y]

            if cell is Sun:
                return True
            elif cell is Non_Empty_Symbol:
                break

        # Check column down
        for row in range(self.x + 1, self.picture_size):
            cell = self.graph[row][self.y]

            if cell is Sun:
                return True
            elif cell is Non_Empty_Symbol:
                break

        # Check row right
        for column in range(self.y + 1, self.picture_size):
            cell = self.graph[self.x][column]

            if cell is Sun:
                return True
            elif cell is Non_Empty_Symbol:
                break

        # Check row left
        for column in range(self.y - 1, -1, -1):
            cell = self.graph[self.x][column]

            if cell is Sun:
                return True
            elif cell is Non_Empty_Symbol:
                break

        # Check diagonal up-right
        for diagonal in range(1, self.picture_size):
            index_row = self.x - diagonal
            index_col = self.y + diagonal

            try:
                cell = self.graph[index_row][index_col]
            except IndexError:
                break

            if cell is Sun:
                return True
            elif cell is Non_Empty_Symbol:
                break

        # Check diagonal up-left
        for diagonal in range(1, self.picture_size):
            index_row = self.x - diagonal
            index_col = self.y - diagonal

            try:
                cell = self.graph[index_row][index_col]
            except IndexError:
                break

            if cell is Sun:
                return True
            elif cell is Non_Empty_Symbol:
                break

        # Check diagonal down-right
        for diagonal in range(1, self.picture_size):
            index_row = self.x + diagonal
            index_col = self.y + diagonal

            try:
                cell = self.graph[index_row][index_col]
            except IndexError:
                break

            if cell is Sun:
                return True
            elif cell is Non_Empty_Symbol:
                break

        # Check diagonal down-left
        for diagonal in range(1, self.picture_size):
            index_row = self.x + diagonal
            index_col = self.y - diagonal

            try:
                cell = self.graph[index_row][index_col]
            except IndexError:
                break

            if cell is Sun:
                return True
            elif cell is Non_Empty_Symbol:
                break

        return False

    # For house
    def check_view_up(self):
        for row in range(self.x - 1, -1, -1):
            cell = self.graph[row][self.y]
            if cell is Non_Empty_Symbol:
                break
            else:
                cell.add_to_generate_value(10)

    def check_view_down(self):
        for row in range(self.x, self.picture_size):
            cell = self.graph[row][self.y]
            if cell is Non_Empty_Symbol:
                break
            else:
                cell.add_to_generate_value(5)

    # For animals
    # ANIMALS 1
    def animals_first_condition(self):
        try:
            cell = self.graph[self.x + 1][self.y]
            if cell is Empty_Symbol:
                self.add_to_generate_value(15)
        except IndexError:
            pass
        try:
            cell = self.graph[self.x - 1][self.y]
            if cell is Empty_Symbol:
                self.add_to_generate_value(15)
        except IndexError:
            pass
        try:
            cell = self.graph[self.x][self.y - 1]
            if cell is Empty_Symbol:
                self.add_to_generate_value(15)
        except IndexError:
            pass
        try:
            cell = self.graph[self.x][self.y + 1]
            if cell is Empty_Symbol:
                self.add_to_generate_value(15)
        except IndexError:
            pass

    # DRAKE/GRILL
    def is_drake_grill(self, spec_type):
        try:
            cell = self.graph[self.x + 1][self.y]
            if cell is spec_type:
                return True
        except IndexError:
            pass
        try:
            cell = self.graph[self.x - 1][self.y]
            if cell is spec_type:
                return True
        except IndexError:
            pass
        try:
            cell = self.graph[self.x][self.y - 1]
            if cell is spec_type:
                return True
        except IndexError:
            pass
        try:
            cell = self.graph[self.x][self.y + 1]
            if cell is spec_type:
                return True
        except IndexError:
            pass

        return False


class Sun(Non_Empty_Symbol):
    def __init__(self, position, picture_size):
        super().__init__(position, picture_size)


class House(Non_Empty_Symbol):
    def __init__(self, position, picture_size):
        super().__init__(position, picture_size)


class Peaks(Non_Empty_Symbol):
    def __init__(self, position, picture_size):
        super().__init__(position, picture_size)


class Grill(Non_Empty_Symbol):
    def __init__(self, position, picture_size):
        super().__init__(position, picture_size)


class Animal(Non_Empty_Symbol):
    def __init__(self, position, picture_size):
        super().__init__(position, picture_size)


class Slope(Non_Empty_Symbol):
    def __init__(self, position, picture_size, is_left):
        super().__init__(position, picture_size)
        self.is_left = is_left

    def get_is_left(self):
        return self.is_left


class Bird(Animal):
    def __init__(self, position, picture_size):
        super().__init__(position, picture_size)


class Drake(Bird):
    def __init__(self, position, picture_size):
        super().__init__(position, picture_size)


class Chupacabra(Animal):
    def __init__(self, position, picture_size):
        super().__init__(position, picture_size)


def decode_input(char, nextChar, position, size):
    new_obj = None
    if char == ' ':
        new_obj = Empty_Symbol(position, size)
    elif char == '*':
        new_obj = Sun(position, size)
    elif char == '^':
        new_obj = House(position, size)
    elif char == '!':
        new_obj = Chupacabra(position, size)
    elif char == '/':
        if nextChar == "\\":
            new_obj = Peaks(position, size)
        else:
            new_obj = Slope(position, size, True)
    elif char == "\\":
        new_obj = Slope(position, size, False)
    elif char == 'v':
        new_obj = Bird(position, size)
    elif char == 'D':
        new_obj = Drake(position, size)
    elif char == 'G':
        new_obj = Grill(position, size)

    return new_obj


if __name__ == "__main__":
    # Read input
    size = int(input())
    picture = Picture(size)
    for i in range(size):
        row = input()
        for char_index in range(0, len(row)):
            char = row[char_index]
            nextChar = ""
            if char_index != len(row)-1:
                nextChar = row[char_index + 1]

            el = decode_input(char, nextChar, [i, char_index], size)
            el.set_picture(picture)
            picture.add_element(el)
            if el is Peaks:
                char_index += 1

    graph = picture.get_graph()
    for elements_row in graph:
        for element in elements_row:
            if type(element) == type(int):
                picture.get_graph().remove(element)
            el_x, el_y = element.get_pos()
            try:
                cell = graph[el_x + 1][el_y]
                element.add_adjacent_cell(cell)
            except IndexError:
                pass
            try:
                cell = graph[el_x - 1][el_y]
                element.add_adjacent_cell(cell)
            except IndexError:
                pass
            try:
                cell = graph[el_x][el_y - 1]
                element.add_adjacent_cell(cell)
            except IndexError:
                pass
            try:
                cell = graph[el_x][el_y + 1]
                element.add_adjacent_cell(cell)
            except IndexError:
                pass
    print(picture.calculate_total_value())