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 static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Short.parseShort;
import static java.lang.Byte.parseByte;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Contest {

    static int nextInt() throws IOException {
        return parseInt(next());
    }

    static long nextLong() throws IOException {
        return parseLong(next());
    }

    static short nextShort() throws IOException {
        return parseShort(next());
    }

    static byte nextByte() throws IOException {
        return parseByte(next());
    }

    static String next() throws IOException {
        while (tok == null || !tok.hasMoreTokens())
            tok = new StringTokenizer(in.readLine());
        return tok.nextToken();
    }

    static String nextLine() throws IOException {
        return in.readLine();
    }

    private static BufferedReader in;
    private static StringTokenizer tok;
    private static PrintWriter out = new PrintWriter(System.out);
    private static Utilities doThis = new Utilities();

    public static void main(String[] args) throws Exception {
        in = new BufferedReader(new InputStreamReader(System.in));

        /*--------------------SolutionStarted-------------------*/
        solve();
        /*--------------------SolutionEnded--------------------*/

        in.close();
        out.close();
    }



    static void solve() throws IOException {
        char[][] desks = new char[nextInt()][nextInt()];
        char s = next().charAt(0);
        HashSet<Character> deputies = new HashSet<>(10000);
        for (int i = 0; i <desks.length ; i++)
            desks[i] = next().toCharArray();
        for (int i = 0; i <desks.length ; i++) {
            for (int j = 0; j <desks[i].length ; j++) {
                if (desks[i][j]==s) {
                    if (i != 0) {
                        if (desks[i - 1][j] != '.' && desks[i - 1][j] != s)
                            deputies.add(desks[i - 1][j]);
                    }
                    if (i != desks.length - 1) {
                        if (desks[i + 1][j] != '.' && desks[i + 1][j] != s)
                            deputies.add(desks[i + 1][j]);
                    }
                    if (j!=0){
                        if (desks[i][j-1] != '.' && desks[i][j-1] != s)
                            deputies.add(desks[i][j-1]);
                    }
                    if (j!=desks[i].length-1){
                        if (desks[i][j+1] != '.' && desks[i][j+1] != s)
                            deputies.add(desks[i][j+1]);
                    }
                }
            }
        }
        out.println(deputies.size());
    }
    static boolean equals(char a, char b){
        return a==b;
    }
    static void swap(char[] s, int a,int b){
        char temp =s[b];
        s[b]= s[a];
        s[a] = temp;
    }
    static boolean odd(int a){
        return a%2==1;
    }
    static boolean even(int a){
        return a%2==0;
    }
    static void yes(){
        out.println("YES");
        out.close();
        System.exit(0);
    }
    static void no() {
        out.println("NO");
        out.close();
        System.exit(0);
    }
    static void bad(){
        out.println(-1);
        out.close();
        System.exit(0);
    }
}
class IntPair implements Comparable<IntPair> {
    int teamID, points;

    IntPair(int teamID, int points) {
        this.teamID = teamID;
        this.points = points;
    }

    @Override
    public int compareTo(IntPair o) {
        if (teamID == o.teamID)
            return 0;
        if (points == o.points)
            return o.teamID - teamID;
        return points - o.points;
    }

    public String toString() {
        return teamID + " " + points;
    }
}
class CharPair{
    char c;
    boolean flag;
    CharPair(char c, boolean flag){
        this.c = c;
        this.flag = flag;
    }
}
class BooleanPair {
    boolean key, value;

    BooleanPair() {
    }

    BooleanPair(boolean key, boolean value) {
        this.key = key;
        this.value = value;
    }
}
class Utilities {
    //int arrays start
    int lowerBound(int[] arr, int low, int high, int element) {
        int middle;
        while (low < high) {
            middle = low + (high - low) / 2;
            if (element > arr[middle])
                low = middle + 1;
            else
                high = middle;
        }
        if (arr[low] < element)
            return -1;
        return low;
    }

    int upperBound(int[] arr, int low, int high, int element) {
        int middle;
        while (low < high) {
            middle = low + (high - low) / 2;
            if (arr[middle] > element)
                high = middle;
            else
                low = middle + 1;
        }
        if (arr[low] <= element)
            return -1;
        return low;
    }
    //int arrays end
    //long arrays start
    int lowerBound(long[] arr, int low, int high, long element) {
        int middle;
        while (low < high) {
            middle = low + (high - low) / 2;
            if (element > arr[middle])
                low = middle + 1;
            else
                high = middle;
        }
        if (arr[low] < element)
            return -1;
        return low;
    }

    int upperBound(long[] arr, int low, int high, long element) {
        int middle;
        while (low < high) {
            middle = low + (high - low) / 2;
            if (arr[middle] > element)
                high = middle;
            else
                low = middle + 1;
        }
        if (arr[low] <= element)
            return -1;
        return low;
    }
    //long arrays end
    //double arrays start
    int lowerBound(double[] arr, int low, int high, double element) {
        int middle;
        while (low < high) {
            middle = low + (high - low) / 2;
            if (element > arr[middle])
                low = middle + 1;
            else
                high = middle;
        }
        if (arr[low] < element)
            return -1;
        return low;
    }

    int upperBound(double[] arr, int low, int high, double element) {
        int middle;
        while (low < high) {
            middle = low + (high - low) / 2;
            if (arr[middle] > element)
                high = middle;
            else
                low = middle + 1;
        }
        if (arr[low] <= element)
            return -1;
        return low;
    }
    //double arrays end
}