President of Berland has a very vast office-room, where, apart from him, work his subordinates. Each subordinate, as well as President himself, has his own desk of a unique colour. Each desk is rectangular, and its sides are parallel to the office walls. One day President decided to establish an assembly, of which all his deputies will be members. Unfortunately, he does not remember the exact amount of his deputies, but he remembers that the desk of each his deputy is adjacent to his own desk, that is to say, the two desks (President's and each deputy's) have a common side of a positive length.

The office-room plan can be viewed as a matrix with n rows and m columns. Each cell of this matrix is either empty, or contains a part of a desk. An uppercase Latin letter stands for each desk colour. The «period» character («.») stands for an empty cell. 

Input

The first line contains two separated by a space integer numbers n, m (1 ≤ n, m ≤ 100) — the length and the width of the office-room, and c character — the President's desk colour. The following n lines contain m characters each — the office-room description. It is guaranteed that the colour of each desk is unique, and each desk represents a continuous subrectangle of the given matrix. All colours are marked by uppercase Latin letters.

Output

Print the only number — the amount of President's deputies.

Examples

Input

3 4 R
G.B.
.RR.
TTT.


Output

2


Input

3 3 Z
...
.H.
..Z


Output

0
import java.awt.*;
import java.io.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

public class Main2 {
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    static BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void write(String string){
        try {
            writer.write(string);
            writer.close();
        } catch (IOException exception){
            throw new IOError(exception);
        }
    }

    public static String readString(){
        try {
            return reader.readLine().trim();
        } catch (IOException exception){
            throw new IOError(exception);
        }
    }
    public static int readInt(){
        return Integer.parseInt(readString());
    }
    public static int[] readInts(){
        String[] parts = readString().split("\\s+");
        int[] integers = new int[parts.length];
        for (int i = 0; i<integers.length; ++i){
            integers[i] = Integer.parseInt(parts[i]);
        }
        return integers;
    }
    public static double readDouble(){
        return Double.parseDouble(readString());
    }
    public static double[] readDoubles(){
        String[] parts = readString().split(" ");
        double[] integers = new double[parts.length];
        for (int i = 0; i<integers.length; ++i){
            integers[i] = Double.parseDouble(parts[i]);
        }
        return integers;
    }

    public static void main(String[] args) {
        StringBuilder builder = new StringBuilder();
        String str = readString();
        char bossChar = str.charAt(str.length()-1);
        String[] nums = str.substring(0, str.length()-2).split(" ");
        int height = Integer.parseInt(nums[0]);
        int width = Integer.parseInt(nums[1]);
        char[][] grid = new char[height][width];
        List<Point> table = new ArrayList<Point>();
        for (int y = 0; y < height; y++){
            grid[y] = readString().toCharArray();
            for (int x = 0; x < width; x++){
                if (grid[y][x] == bossChar){
                    table.add(new Point(x, y));
                }
            }
        }
        HashSet<Character> desks = new HashSet<Character>();
        desks.add('.');
        desks.add(bossChar);
        Point[] offsets = {new Point(0,1), new Point(0,-1), new Point(-1,0), new Point(1,0)};
        for (Point p: table) {
            for (int i = 0; i < 4; i++) {
                try {
                    desks.add(grid[p.y + offsets[i].y][p.x + offsets[i].x]);
                } catch (IndexOutOfBoundsException e) {
                }
            }
        }
        System.out.print(desks.size()-2);
    }

}