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 sys
import os
from io import IOBase, BytesIO
# import heapq
# import math
# import collections
# import itertools
# import bisect
mod = 10 ** 9 + 7
pie = 3.1415926536
#import resource
#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])
#import threading
# threading.stack_size(2**27)
#import sys
# sys.setrecursionlimit(10**6)
# fact=[1]
# for i in range(1,1000001):
#    fact.append((fact[-1]*i)%mod)
# ifact=[0]*1000001
# ifact[1000000]=pow(fact[1000000],mod-2,mod)
# for i in range(1000000,0,-1):
#    ifact[i-1]=(i*ifact[i])%mod
#from random import randint as rn
#from Queue import Queue as Q


def modinv(n, p):
    return pow(n, p-2, p)


def ncr(n, r, p):  # for using this uncomment the lines calculating fact and ifact
    t = ((fact[n])*((ifact[r]*ifact[n-r]) % p)) % p
    return t


def ain():  # takes array as input
    return list(map(int, sin().split()))


def sin():
    return input().strip()


def GCD(x, y):
    while(y):
        x, y = y, x % y
    return x


def readIntArray(size):
    # return list(map(int, input().strip().split()))[:size]
    arr = []
    for i in range(0, size):
        temp = int(sin().split())
        arr.append(temp)
    return arr


def readStringArray(size):
    return list(map(str, input().strip().split()))[:size]


def readFloatArray(size):
    return list(map(float, input().strip().split()))[:size]


def read2DIntArray(row, col):
    arr = []
    for i in range(0, row):
        temp = list(map(int, sin().split()))
        arr.append(temp)

    return arr


def read2DCharArray(row, col):
    arr = []
    for i in range(0, row):
        temp = str(sin())
        arr.append(temp)

    return arr


def read2DStringArray(row, col):
    return [[str(input()) for x in range(col)] for y in range(row)]


def read2DFloatArray(row, col):
    return [[float(input()) for x in range(col)] for y in range(row)]


"""***************************************************************************************"""


def main():
    n, m, c = sin().split()
    n = int(n)
    m = int(m)
    c = str(c)
    arr = read2DCharArray(n, m)

    temp = []
    ans = 0

    for i in range(0, n):
        for j in range(0, m):
            if (arr[i][j] == c):
                if ((i - 1 >= 0) and (arr[i - 1][j] != '.') and (arr[i - 1][j] != c) and (arr[i - 1][j] not in temp)):
                    ans += 1
                    temp.append(arr[i - 1][j])
                if ((i + 1 < n) and (arr[i + 1][j] != '.') and (arr[i + 1][j] != c) and (arr[i + 1][j] not in temp)):
                    ans += 1
                    temp.append(arr[i + 1][j])
                if ((j - 1 >= 0) and (arr[i][j-1] != '.') and (arr[i][j-1] != c) and (arr[i][j-1] not in temp)):
                    ans += 1
                    temp.append(arr[i][j-1])
                if ((j + 1 < m) and (arr[i][j+1] != '.') and (arr[i][j+1] != c) and (arr[i][j+1] not in temp)):
                    ans += 1
                    temp.append(arr[i][j + 1])

    print(ans)


"""***************************************************************************************"""

# Python 2 and 3 footer by Pajenegod and c1729
py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2),
                   super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode('ascii'))
            self.read = lambda: self.buffer.read().decode('ascii')
            self.readline = lambda: self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def input(): return sys.stdin.readline().rstrip('\r\n')


if __name__ == '__main__':
    main()
# threading.Thread(target=main).start()
