Sergey recently learned about country codes - two letter strings, denoting countries. For example, BY stands for Belarus and IN stands for India. Mesmerized by this new discovery, Sergey now looks for country codes everywhere!
Sergey has recently found a string S consisting of uppercase Latin letters. He wants to find the number of different country codes that appear in S as contiguous substrings. For the purpose of this problem, consider that every 2-letter uppercase string is a valid country code.

-----Input-----
The first line of input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first and only line of each test case contains a string S, consisting of uppercase Latin letters.

-----Output-----
For each test case, output a single line containing the number of different country codes appearing in the given string.

-----Constraints-----

- 1 ≤ T ≤ 100
- Subtask 1 (35 points): 2 ≤ |S| ≤ 3
- Subtask 2 (65 points): 2 ≤ |S| ≤ 104

-----Example-----
Input:2
INBY
BYBY

Output:3
2

-----Explanation-----
Example case 1. The codes are IN, NB and BY.
Example case 2. The codes are BY and YB.

Starter code:

Solutions:
#import set
t = eval(input())  
while(t):
    s = input()
    set1 = set()
    j = 0
    for i in s[:-1]:
        a = s[j:j+2]
        set1.add(a)
        j = j + 1
    print(str(len(set1)) + '\n')
    t= t-1
 


def bck():
    t=eval(input())
    for i in range(t):
        s=input()
        l=[]
        ch=""
        i=0
        while(i!=len(s)-1):
            ch=s[i]+s[i+1]
            l.append(ch)
            i=i+1
        l=set(l)
        print(len(l))
bck()
            
                


t=int(eval(input()))
while t:
    a=[]
    t=t-1
    s=input()
    a.append(s[:2])
    for i in range(1,len(s)-1):
        c=s[i:i+2]
        if c not in a:
            a.append(c)
    print(str(len(a)))
    

t=eval(input())

while t>0:
    a=[[0 for x in range(26)] for x in range(26)]
    ans=0
    t-=1
    s=list(input())
    for i in range(len(s)-1):
        #print s[i]
        if a[ord(s[i])-65][ord(s[i+1])-65]==0:
            #print s[i],"hello"
            a[ord(s[i])-65][ord(s[i+1])-65]=1
            ans+=1
    print(ans)


t = eval(input())
while t:
    s = input()
    country = []
    for i in range(len(s)-1):
        temp = s[i] + s[i+1]
        country += [temp]
    country  = set(country)    
    print(len(country))
    t-=1


import sys

def work():

	j=eval(input())
	for k in range(j):
		s=input()
		a=''
		count=0
		for i in range(1,len(s)):
			s1=s[i-1]+s[i]
			if a.find(s1) == -1:
				a=a+s1
				count+=1
#				print a.find(s1)
#				print s1
#				print a
		print(count)

def main():
	work()


def __starting_point():
	main()
__starting_point()

t = int(input())
while(t):
	a = []
	string = list(input())
	for i in range(len(string)-1):
		a.append(str(string[i])+str(string[i+1]))

	a = set(a)
	print(len(a))
	t-=1

t=int(input())
while t>0 :
    t-=1
    s=input()
    d=dict()
    for i in range(0,len(s)-1) :
        word=s[i:i+2]
        d[word]=d.get(word,0)+1
    print(len(d))


t = eval(input())
for _ in range(t):
	s = input()
	d = []
	l = len(s)
	for a in range(l-1):
		d.append(s[a:a+2])
	d = set(d)
	print(len(d))

t=eval(input())
for i in range(1,t+1):
    a=input();l=[]
    for i in range(len(a)-1):
        l+=[a[i]+a[i+1]]
    l=set(l)
    print(len(l))

t = eval(input())
for _ in range(t):
	s = input()
	d = []
	l = len(s)
	for a in range(l-1):
		d.append(s[a:a+2])
	d = set(d)
	print(len(d))

def extract(s):
    codes = {}
    for i in range(len(s) - 1):
        cc = s[i:i + 2]
        if cc not in codes:
            codes[cc] = True
    return len(codes)

t = int(input())

for i in range(t):
    print(extract(input()))
    



import sys
t=int(input(""))
while t:
    l2=[]
    count=0
    l=str(input(""))
    for i in range(len(l)-1):
        x=l[i]+l[i+1]
        if x not in l2:
            l2.append(x)
            count+=1
    print(count)
    t-=1

        
    


for _ in range(eval(input())):
    arr=[None]*677
    inp=input()
    l=len(inp)
    for i in range(l-1):
        a=inp[i]
        b=inp[i+1]
        num=(ord(a)-65)*26 + (ord(b)-65) + 1 
        #print num
        arr[num]=1
    codes=0    
    for i in arr:
        if i==1:
            codes+=1
    print(codes)

def bck():
    t=eval(input())
    for i in range(t):
        s=input()
        l=[]
        ch=""
        i=0
        while(i!=len(s)-1):
            ch=s[i]+s[i+1]
            l.append(ch)
            i=i+1
        for j in l:
            if j in l[l.index(j)+1:]:
                l.remove(j)
        print(len(l))
bck()
            
                


for _ in range(int(input())):
    s=input()
    l=[s[i:i+2] for i in range(len(s)-1)]
    print(len(set(l)))


for _ in range(int(input())):
    a=input()
    s=set([])
    for i in range(len(a)-1):
        s.add(a[i:i+2])
    print(len(s))

for a in range(int(input())):
    arr = []
    s = input().strip()
    for i in range(len(s) - 1):
        if not(s[i:i + 2] in arr):
            arr.append(s[i:i + 2])
    print(len(arr))

t = eval(input())
for i in range(t):
	string = input()
	l = len(string)
	aset = set()
	for i in range(l-1):
		aset.add(string[i:i+2])
	print(len(aset))

for i in range(int(input())):
  s=input()
  l=[]
  for j in range(len(s)-1):
    l.append(s[j:j+2])
  print(len(set(l)))



import fractions
import sys

f = sys.stdin

if len(sys.argv) > 1:
    f = open(sys.argv[1], "rt")


def calc(s):
    codes = set()
    for i in range(1, len(s)):
        ch1 = s[i-1]
        ch2 = s[i]
        codes.add((ch1, ch2))
    return len(codes)

T = int(f.readline().strip())

for case_id in range(1, T+1):
    s = f.readline().strip()

    r = calc(s)

    print(r)


import sys

t = eval(input())
for _ in range(t):
	s = list(map(str, sys.stdin.readline().split()))[0]
	n = len(s)
	d = {}
	for i in range(1,n):
		k = s[i-1:i+1]
		if k not in d:
			d[k] = 0
	print(len(list(d.keys())))