This is a simplified version of the problem B2. Perhaps you should read the problem B2 before you start solving B1.

Paul and Mary have a favorite string $s$ which consists of lowercase letters of the Latin alphabet. They want to paint it using pieces of chalk of two colors: red and green. Let's call a coloring of a string wonderful if the following conditions are met:

each letter of the string is either painted in exactly one color (red or green) or isn't painted;

each two letters which are painted in the same color are different;

the number of letters painted in red is equal to the number of letters painted in green;

the number of painted letters of this coloring is maximum among all colorings of the string which meet the first three conditions.

E. g. consider a string $s$ equal to "kzaaa". One of the wonderful colorings of the string is shown in the figure.

The example of a wonderful coloring of the string "kzaaa".

Paul and Mary want to learn by themselves how to find a wonderful coloring of the string. But they are very young, so they need a hint. Help them find $k$ — the number of red (or green, these numbers are equal) letters in a wonderful coloring.


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 1000$) — the number of test cases. Then $t$ test cases follow.

Each test case consists of one non-empty string $s$ which consists of lowercase letters of the Latin alphabet. The number of characters in the string doesn't exceed $50$.


-----Output-----

For each test case, output a separate line containing one non-negative integer $k$ — the number of letters which will be painted in red in a wonderful coloring.


-----Examples-----

Input
5
kzaaa
codeforces
archive
y
xxxxxx
Output
2
5
3
0
1


-----Note-----

The first test case contains the string from the statement. One of the wonderful colorings is shown in the figure. There's no wonderful coloring containing $3$ or more red letters because the total number of painted symbols will exceed the string's length.

The string from the second test case can be painted as follows. Let's paint the first occurrence of each of the letters "c", "o", "e" in red and the second ones in green. Let's paint the letters "d", "f" in red and "r", "s" in green. So every letter will be painted in red or green, hence the answer better than $5$ doesn't exist.

The third test case contains the string of distinct letters, so you can paint any set of characters in red, as long as the size of this set doesn't exceed half of the size of the string and is the maximum possible.

The fourth test case contains a single letter which cannot be painted in red because there will be no letter able to be painted in green.

The fifth test case contains a string of identical letters, so there's no way to paint more than one letter in red.

Source: codeforces | Difficulty: EASY
Tags: String algorithms

Greedy algorithms


Solutions:
numberOfTests = int(input())
dictionary = {}
for q in range(numberOfTests):
	string = input()
	counterRed = 0
	counterGreen = 0
	switch = 0
	for x in range(len(string)):
		if x not in dictionary:
			dictionary[string[x]] = []
	for x in range(len(string)):
		if len(dictionary[string[x]]) == 2:
			continue
		if len(dictionary[string[x]]) == 1 and dictionary[string[x]] == 'red':
			dictionary[string[x]].append('green')
			switch = 0
			counterGreen += 1
			continue
		if len(dictionary[string[x]]) == 1 and dictionary[string[x]] == 'green':
			dictionary[string[x]].append('red')
			switch = 1
			counterRed += 1
			continue
		if switch == 0:
			dictionary[string[x]].append('red')
			counterRed += 1
			switch = 1
		else:
			dictionary[string[x]].append('green')
			counterGreen += 1
			switch = 0
	if counterRed == counterGreen:
		print(counterRed)
	else:
		print(min(counterRed, counterGreen))


for _ in range(int(input())):
	s = input()
	w = list(set(s))
	count = 0
	r = 0
	for i in range(len(w)):
		if s.count(w[i]) >= 2:
			count += 1
		else:
			r += 1
	print(count + r // 2)


from collections import defaultdict
t = int(input())
for i in range(1, t + 1):
	ls = input()
	dic = defaultdict(list)
	for (idx, ch) in enumerate(ls):
		if len(dic[ch]) < 2:
			dic[ch].append(idx)
	count = 0
	for ch in dic:
		for idx in dic[ch]:
			count += 1
	count = count // 2
	print(count)


for i in range(int(input())):
	s = input()
	painted = []
	for ss in s:
		if ss not in painted:
			painted.append(ss)
		elif ss in painted:
			sss = ss + ss
			if sss not in painted:
				painted.append(sss)
			else:
				continue
	print(len(painted) // 2)


from collections import Counter
t = int(input(' '))
for i in range(0, t):
	st = input(' ')
	vals = Counter(st)
	rd = 0
	gd = 0
	sol = 0
	for i in vals:
		if vals[i] >= 2:
			rd = rd + 1
		elif vals[i] == 1:
			gd = gd + 1
	sol = rd + gd // 2
	print(sol)


from sys import stdin

def A():
	t = int(stdin.readline())
	while t:
		t -= 1
		n = int(stdin.readline())
		if n % 3 == 0:
			print(n // 3, end=' ')
			print(n // 3)
			continue
		sav = n // 3
		while (n - sav) % 2 != 0:
			sav += 1
		print(sav, end=' ')
		print((n - sav) // 2)

def B():
	t = int(stdin.readline())
	while t:
		t -= 1
		s = input()
		d = [0] * 27
		for i in s:
			c = ord(i) - ord('a')
			d[c] += 1
		cnt = 0
		cnt1 = 0
		for i in range(0, 27):
			if d[i] == 0:
				continue
			if d[i] % 2 == 0:
				cnt += 1
			elif d[i] >= 3:
				cnt += 1
			else:
				cnt1 += 1
		print(cnt + cnt1 // 2)
B()


t = int(input())
for i in range(t):
	s = input()
	l = len(s)
	s = list(s)
	m = set(s)
	contador = 0
	li = []
	for j in m:
		li.append(s.count(j))
	for j in li:
		if j == 1:
			contador += 1
	p = len(li) - contador
	f = int(contador / 2)
	print(p + f)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import ceil

def prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	return ans

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

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	s = input()
	ans = 0
	bal = 0
	count = [0] * 26
	for i in s:
		count[ord(i) - 97] += 1
	for i in range(26):
		if count[i] > 1:
			ans += 1
		elif count[i]:
			bal += 1
			if bal == 2:
				ans += 1
				bal = 0
	print(ans)


for i in range(int(input())):
	s = input()
	d = {}
	for i in s:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	c1 = 0
	c2 = 0
	for i in d:
		if d[i] >= 2:
			c2 += 1
		else:
			c1 += 1
	print(c2 + c1 // 2)


t = int(input())
for r in range(t):
	str = input()
	s = set(str)
	c = 0
	d = 0
	while len(s) > 0:
		e = s.pop()
		i = str.count(e)
		if i > 1:
			d = d + 1
		else:
			c = c + 1
	print(c // 2 + d)


for _ in range(int(input())):
	s = input()
	c = 0
	k = 0
	l = []
	for i in s:
		z = s.count(i)
		if z == 1:
			c += 1
		elif z > 1 and i not in l:
			k += 1
			l.append(i)
	print(c // 2 + k)


import itertools
from collections import Counter, defaultdict

def structure(arr):
	d = defaultdict(list)
	for i in range(len(arr)):
		d[arr[i]].append(i)
	return d

def color_arr(arr, max_colors):
	n = len(arr)
	d = structure(arr)
	colored = [0] * n
	all_ = 0
	for k in d.keys():
		bound = min(max_colors, len(d[k]))
		d[k] = d[k][:bound]
		assert len(d[k]) <= max_colors
		all_ += len(d[k])
	all_ = all_ // max_colors * max_colors
	color_range = itertools.cycle(range(1, 1 + max_colors))
	for i in itertools.islice(itertools.chain(*d.values()), all_):
		colored[i] = next(color_range)
	return colored

def index_of_sorted(sorted_, start, cnt):
	for j in range(start, len(sorted_)):
		if sorted_[j] > cnt:
			return j
	return len(sorted_)

def solve():
	arr = list(input())
	(n, k) = (len(arr), 2)
	d = structure(arr)
	sorted_ = [len(x) for x in d.values()]
	sorted_.sort()
	max_colors = k
	N = len(sorted_)
	index = index_of_sorted(sorted_, 0, k)
	le_index = sum(sorted_[:index])
	how_many = le_index // max_colors * max_colors + max_colors * (N - index)
	return len([x for x in color_arr(arr, max_colors) if x == 1])
for _ in range(int(input())):
	print(solve())


import collections
t = int(input())
for _ in range(t):
	s = input()
	gr = dict(collections.Counter(s))
	c1 = 0
	c2 = 0
	for i in gr.keys():
		if gr[i] >= 2:
			c1 += 1
		else:
			c2 += 1
	print(c1 + c2 // 2)


import os, sys
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import *
from collections import defaultdict, deque, Counter
import math, string
from heapq import *
from operator import add
from itertools import accumulate
BUFSIZE = 8192
sys.setrecursionlimit(10 ** 5)

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
inf = float('inf')
en = lambda x: list(enumerate(x))
ceil_ = lambda a, b: (a + b - 1) // b
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())

def solve():
	s = list(input())
	arr = Counter(s)
	c = d = 0
	for i in arr.values():
		if i > 1:
			c += 1
		else:
			d += 1
	print(c + d // 2)
for _ in ' ' * ii():
	solve()


from collections import Counter
n = int(input())
for i in range(n):
	a = input()
	b = Counter(a)
	x = 0
	y = 0
	for i in b:
		if b[i] >= 2:
			x += 1
		else:
			y += 1
	print(x + y // 2)


try:
	T = int(input())
	for i in range(T):
		s = input()
		if len(s) == 1:
			print(0)
		else:
			d = dict()
			for i in s:
				if i in d:
					d[i] += 1
				else:
					d[i] = 1
			if len(d) == 1:
				print(1)
			else:
				(co, cm) = (0, 0)
				for i in d:
					if d[i] == 1:
						co += 1
					else:
						cm += 1
				co //= 2
				print(co + cm)
except:
	pass


for _ in range(int(input())):
	s = list(input())
	red = []
	green = []
	s.sort()
	for i in s:
		if i not in red:
			red.append(i)
		elif i not in green:
			green.append(i)
		else:
			pass
	diff = abs(len(red) - len(green)) // 2
	print(diff + len(green))


import sys, os.path
from collections import defaultdict as dd
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(int(input())):
	s = input()
	n = len(s)
	d = dd(int)
	for i in range(n):
		d[s[i]] += 1
	ans = 0
	for i in d:
		ans += min(d[i], 2)
	print(ans // 2)


import sys
import math
import collections
import heapq
import decimal
t = int(input())
for w in range(t):
	s = list(input())
	d = collections.Counter(s)
	(c1, c2) = (0, 0)
	for i in d:
		if d[i] == 1:
			if c1 < c2:
				c1 += 1
			else:
				c2 += 1
		else:
			c1 += 1
			c2 += 1
	print(min(c1, c2))


tc = int(input())
for i in range(tc):
	x = input()
	y = x
	list1 = []
	for i in y:
		list1.append(i)
	list1 = set(list1)
	str1 = ''
	for i in list1:
		str1 += i
	str2 = ''
	str3 = []
	for i in str1:
		if x.count(i) == 1:
			str2 += i
		else:
			str3 += [i]
	print(len(str2) // 2 + len(str3))


def f(s):
	A = ''
	B = ''
	for i in s:
		if i not in A:
			A = A + i
		else:
			B = B + i
	return (A, B)
z = int(input())
while z > 0:
	s = input()
	(A, B) = f(s)
	(C, D) = f(B)
	print((len(A) + len(C)) // 2)
	z = z - 1


import collections

def solve():
	s = input()
	counts = collections.Counter(s)
	ans = 0
	distinct = set()
	for (i, x) in counts.items():
		if x > 1:
			ans += 1
		else:
			distinct.add(i)
	print(ans + len(distinct) // 2)
t = int(input())
for i in range(1, t + 1):
	solve()


t = int(input())
c = 0
o = 0
for i in range(t):
	s = input()
	c = 0
	o = 0
	while s != '':
		if s.count(s[0]) > 1:
			c += 1
			s = s.replace(s[0], '')
		else:
			o += 1
			s = s.replace(s[0], '')
	c += o // 2
	print(c)


from collections import defaultdict

def solve(s):
	if len(s) == 1:
		return 0
	ans = 0
	d = defaultdict(int)
	for i in s:
		d[i] += 1
	ones = 0
	twos = 0
	for i in d:
		if d[i] == 1:
			ones += 1
		if d[i] >= 2:
			twos += 1
	ans = ones // 2 + twos
	return ans
for _ in range(int(input())):
	n = input()
	print(solve(n))


for i in range(int(input())):
	strn = input()
	r = 0
	g = 0
	all_freq = {}
	for i in strn:
		if i in all_freq:
			all_freq[i] += 1
		else:
			all_freq[i] = 1
	count = 0
	for key in all_freq:
		if all_freq[key] >= 2:
			r += 1
			g += 1
		else:
			count += 1
	if count % 2 == 0:
		r += count // 2
	else:
		r += (count - 1) // 2
	print(r)


t = int(input())
while t:
	s = input()
	s1 = set(s)
	(ans, l) = (0, 0)
	for i in s1:
		if s.count(i) >= 2:
			ans += 1
		else:
			l += 1
	ans += l // 2
	print(ans)
	t -= 1


def work(n):
	arr = [0] * 26
	for i in n:
		arr[ord(i) - 97] += 1
	s = t = 0
	for i in arr:
		if i == 1:
			s += 1
		elif i >= 2:
			t += 2
	print(s // 2 + t // 2)
for _ in range(int(input())):
	work(input())


import math
from collections import defaultdict
n = int(input())
while n:
	string = input()
	fre = defaultdict(int)
	for i in string:
		fre[i] += 1
	ans = 0
	temp = 0
	for key in fre:
		if fre[key] >= 2:
			ans += 1
		elif fre[key] == 1:
			temp += 1
	print(ans + temp // 2)
	n -= 1


from collections import Counter
for _ in range(int(input())):
	s = Counter(input())
	ans = 0
	for count in s.values():
		ans += min(count, 2)
	print(ans // 2)


T = int(input())
while T:
	s = input()
	longitud = 0
	letras = {}
	for c in s:
		if c not in letras:
			letras[c] = 1
			longitud += 1
		else:
			letras[c] += 1
		if letras[c] == 2:
			longitud += 1
	ans = longitud // 2
	print(ans)
	T -= 1


while True:
	try:
		t = eval(input())
		for i in range(t):
			list0 = list(input())
			list1 = list(set(list0))
			ans = 0
			for j in list1:
				if list0.count(j) >= 2:
					ans += 2
				else:
					ans += 1
			print(ans // 2)
	except:
		break


t = int(input())
for _ in range(t):
	s = input()
	h = {}
	for i in s:
		if i in h:
			h[i] = h[i] + 1
		else:
			h[i] = 1
	single = 0
	multi = 0
	for i in h:
		if h[i] == 1:
			single = single + 1
		else:
			multi = multi + 1
	res = single // 2 + multi
	print(res)


import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		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))
try:
	(sys.stdin, sys.stdout, sys.stderr) = (open('input.txt', 'r'), open('output.txt', 'w'), open('error.txt', 'w'))
except:
	pass
ii1 = lambda : int(sys.stdin.readline().strip())
is1 = lambda : sys.stdin.readline().strip()
iia = lambda : list(map(int, sys.stdin.readline().strip().split()))
isa = lambda : sys.stdin.readline().strip().split()
mod = int(1000000000.0 + 7)
from collections import *
from math import *
MOD = 1000000007
from collections import *
import bisect
for _ in range(ii1()):
	st = is1()
	dit = Counter(st)
	tmp = 0
	ans = 0
	for i in dit.values():
		if i == 1:
			tmp += 1
		elif i >= 2:
			ans += 1
	print(ans + tmp // 2)


for _ in range(int(input())):
	s = input()
	d = {}
	cnt = 0
	for i in s:
		d[i] = d.get(i, 0) + 1
	for i in s:
		if d[i] > 2:
			cnt += 2
		else:
			cnt += d[i]
		d[i] = 0
	print(cnt // 2)


for i in range(int(input())):
	a = {}
	total = 0
	s = input()
	a = set(s)
	for i in a:
		if s.count(i) == 1:
			total += 1
		else:
			total += 2
	print(total // 2)


for s in [*open(0)][1:]:
	print(sum((min(2, s.count(x)) for x in {*s})) - 1 >> 1)


test = int(input())
for t in range(0, test):
	st = str(input())
	dct = {}
	cnt = 0
	for i in st:
		if not dct.get(i):
			dct[i] = 0
			dct[i] = dct.get(i) + 1
		else:
			dct[i] = dct.get(i) + 1
	for (key, value) in dct.items():
		if value >= 2:
			cnt = cnt + 2
		else:
			cnt = cnt + 1
	print(cnt // 2)


n = int(input())
for i in range(n):
	ans = input()
	sol = 0
	temp = 0
	dict1 = {}
	for j in ans:
		if j not in dict1:
			dict1[j] = 1
		else:
			dict1[j] += 1
	for key in dict1.keys():
		if dict1[key] >= 2:
			sol += 1
		elif dict1[key] == 1:
			temp += 1
	sol += temp // 2
	print(sol)


for i in range(int(input())):
	s = input()
	h = set(s)
	c = 0
	k = 0
	for j in h:
		n = s.count(j)
		if n >= 2:
			c = c + 1
		elif n == 1:
			k = k + 1
	print(c + k // 2)


def solve(s):
	freq = dict()
	for i in s:
		if i in freq.keys():
			freq[i] += 1
		else:
			freq[i] = 1
	ans = 0
	s = 0
	for i in freq.keys():
		if freq[i] >= 2:
			ans += 1
		elif freq[i] == 1:
			s += 1
	return str(ans + s // 2)
t = int(input())
for i in range(t):
	print(solve(input()))


from collections import Counter
for _ in range(int(input())):
	s = input()
	d = Counter(s)
	ans = 0
	for i in d:
		ans += min(2, d[i])
	print(ans // 2)


from math import floor, ceil
for _ in range(int(input())):
	s = input()
	n = len(s)
	if n == 1:
		print(0)
	else:
		d = len(set(s))
		if d == n:
			print(int(n / 2))
		elif d == 1:
			print(1)
		else:
			hash = {}
			for x in s:
				if x not in hash:
					hash[x] = 1
				else:
					hash[x] += 1
			count_1 = 0
			dups = 0
			for (k, v) in hash.items():
				if v == 1:
					count_1 += 1
				else:
					dups += 1
			print(int(count_1 / 2) + dups)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key, lru_cache
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip().split()]

def st():
	return str(input().rstrip())[2:-1]

def val():
	return int(input().rstrip())

def li2():
	return [str(i)[2:-1] for i in input().rstrip().split()]

def li3():
	return [int(i) for i in st()]
cnt = l = n = k = l2 = 0
finalans = currans = 0

def check(tot):
	global cnt, l, n, k, l2, currans, finalans
	currans = [set() for i in range(k)]
	pointer = 0
	for i in l2:
		if i not in currans[pointer % k]:
			currans[pointer % k].add(i)
			pointer += 1
			looprun = 0
			while len(currans[pointer % k]) == tot:
				looprun += 1
				pointer += 1
				if looprun > k:
					break
			if looprun > k:
				break
		else:
			continue
	if min((len(i) for i in currans)) < tot:
		return 0
	finalans = [list(i) for i in currans]
	return 1
for _ in range(val()):
	k = 2
	l = st()
	n = len(l)
	l2 = sorted(l)
	index = defaultdict(list)
	for i in range(n):
		index[l[i]].append(i)
	cnt = Counter(l)
	l1 = sorted(cnt.values(), reverse=1)
	low = 0
	high = n
	while low <= high:
		mid = low + high >> 1
		if check(mid):
			low = mid + 1
		else:
			high = mid - 1
	ans = [0] * n
	if len(finalans[0]) != 0:
		for i in range(k):
			for j in finalans[i]:
				ans[index[j].pop()] = i + 1
	print(len(finalans[-1]))


from collections import defaultdict
t = int(input())
for _ in range(t):
	s = input()
	d = defaultdict(int)
	c1 = 0
	c2 = 0
	for i in range(len(s)):
		d[s[i]] += 1
	for j in d:
		if d[j] > 1:
			c2 += 1
		else:
			c1 += 1
	print(c2 + c1 // 2)


for _ in range(int(input())):
	s = input()
	d = {}
	for i in s:
		d[i] = d.get(i, 0) + 1
	r = 0
	g = 0
	for i in d:
		if d[i] > 1:
			r += 1
			g += 1
		elif r > g:
			g += 1
		else:
			r += 1
	print(min(g, r))


t = int(input())
for i in range(t):
	s = input()
	f = list(s)
	d = {}
	k = 0
	for j in range(len(f)):
		if f[j] not in d.keys():
			d[f[j]] = 1
			k += 1
		elif d[f[j]] < 2:
			d[f[j]] += 1
			k += 1
	print(k // 2)


for i in range(int(input())):
	a = input()
	a = list(a)
	total = 0
	box = []
	for i in a:
		if i not in box:
			box.append(i)
			x = min(2, a.count(i))
			total += x
	print(total // 2)


import sys

def solve():
	s = input()
	A = {}
	for c in s:
		if c not in A:
			A[c] = 0
		A[c] += 1
		if A[c] >= 2:
			A[c] = 2
	coldif = 0
	ans = 0
	for ch in range(ord('a'), ord('z') + 1, 1):
		c = chr(ch)
		if c not in A:
			continue
		if A[c] >= 2:
			ans += 1
		elif A[c] == 1:
			coldif += 1
	ans += coldif // 2
	print(ans)
t = int(input())
for i in range(t):
	solve()


from typing import Counter
t = int(input())
for _ in range(t):
	s = input()
	c = Counter(s)
	sum = 0
	for i in c.values():
		sum += min(i, 2)
	print(sum // 2)


t = int(input())
while t:
	s = input()
	dic = {}
	for i in range(len(s)):
		if s[i] not in dic:
			dic[s[i]] = 1
		else:
			dic[s[i]] += 1
	ans = 0
	val = 0
	for key in dic:
		if dic[key] == 1:
			val += 1
		else:
			ans += 1
	print(ans + val // 2)
	t -= 1


def z(string):
	list1 = []
	list1[:0] = string
	return list1
a = int(input())
b = 0
while b < a:
	c = input()
	d = z(c)
	e = z(c)
	d = list(set(d))
	f = 0
	while f < len(d):
		e.remove(d[f])
		f = f + 1
	e = list(set(e))
	print(len(d + e) // 2)
	b = b + 1


t = int(input())
while t != 0:
	t -= 1
	s = input()
	d = dict()
	for i in s:
		if d.get(i) == None:
			d[i] = 1
		else:
			d[i] += 1
	dop = len(s)
	for i in d:
		dop -= max(0, d[i] - 2)
	print(dop // 2)


t = int(input())
for i in range(t):
	s = list(input())
	uniq = set(s)
	ans = 0
	index = 0
	for c in uniq:
		count = s.count(c)
		if count > 1:
			ans += 1
		else:
			index += 1
			if index == 2:
				ans += 1
				index = 0
	print(ans)


T = int(input())
for t in range(T):
	s = input()
	temp = 0
	for i in set(s):
		temp = temp + (s.count(i) if s.count(i) < 2 else 2)
	print(temp // 2)


t = int(input())
while t > 0:
	s = input()
	dict1 = {}
	total = 0
	for i in range(0, len(s), 1):
		if s[i] in dict1:
			dict1[s[i]] += 1
		else:
			dict1[s[i]] = 1
	for i in dict1:
		if dict1[i] > 1:
			total = total + 2
		else:
			total = total + 1
	print(total // 2)
	t = t - 1


T = lambda : int(input())
l = lambda : input()
for _ in range(T()):
	st = l()
	st = sorted(st)
	(r, g) = ([], [])
	f1 = 0
	f2 = 0
	for _ in range(len(st)):
		if f1 == 0:
			if st[_] not in r:
				r.append(st[_])
				f1 = 1
				f2 = 0
			elif st[_] not in g:
				g.append(st[_])
				f2 = 1
				f1 = 0
		elif f2 == 0:
			if st[_] not in g:
				g.append(st[_])
				f2 = 1
				f1 = 0
			elif st[_] not in r:
				r.append(st[_])
				f1 = 1
				f2 = 0
	print(min(len(r), len(g)))


for _ in range(int(input())):
	s = input()
	l = []
	for i in s:
		if l.count(i) < 2:
			l.append(i)
	print(len(l) // 2)


from collections import Counter
t = int(input())
for _ in range(t):
	s = input()
	counter = Counter(s)
	ones = 0
	for i in counter.values():
		if i == 1:
			ones += 1
	print(ones // 2 + (len(counter) - ones))


t = int(input())
ans = list()
for i in range(t):
	st = input()
	dist = {}
	for j in range(len(st)):
		dist[st[j]] = 0
	for j in range(len(st)):
		if st[j] in dist.keys():
			dist[st[j]] += 1
	val = list(dist.values())
	one = 0
	for j in range(len(val)):
		if val[j] == 1 or val[j] == 2:
			one += val[j]
		else:
			one += 2
	ans.append(int(one / 2))
for i in range(t):
	print(ans[i])


import math
import os
import sys
from math import ceil, floor, sqrt, gcd, factorial
from io import BytesIO, IOBase
from collections import Counter
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		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))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def prog_name():
	s = input()
	if len(s) == 1:
		print(0)
	elif s.count(s[0]) == len(s):
		print(1)
	else:
		sing = []
		red = []
		c = Counter(s)
		for i in s:
			if c[i] == 1:
				sing.append(i)
			else:
				red.append(i)
		cnt = len(set(red))
		cnt += len(set(sing)) // 2
		print(cnt)

def main():
	T = int(input())
	for unique in range(T):
		prog_name()
main()


def eachcase():
	s = input()
	l = {}
	for i in s:
		if i not in l:
			l[i] = 1
		else:
			l[i] += 1
	r = 0
	c = 0
	for v in l:
		if l[v] == 1:
			if r == 0:
				r = 1
			else:
				c += 1
				r = 0
		else:
			c += 1
	print(c)

def main():
	tcs = int(input())
	for tc in range(tcs):
		eachcase()
main()


def solve():
	s = input()
	d = dict()
	for c in s:
		if c in d:
			d[c] += 1
		else:
			d[c] = 1
	ans = 0
	temp = 0
	for x in d:
		if d[x] > 1:
			ans += 1
		else:
			temp += 1
	print(ans + temp // 2)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for i in range(t):
	s = input().replace('', ' ').split()
	u = 0
	r = 0
	for a in set(s):
		if s.count(a) == 1:
			u += 1
		else:
			r += 1
	print(r + u // 2)


t = int(input())
tmp = []
for tt in range(t):
	s = input()
	l = len(s)
	arr = []
	k = 0
	if l < 2:
		tmp.append(0)
	else:
		for i in s:
			cc = s.count(i)
			if cc < 3:
				arr.append(cc)
			else:
				arr.append(2)
			s = s.replace(i, '')
		tmp.append(sum(arr))
for c in tmp:
	print(c // 2)


t = int(input())
ans = []
for i in range(t):
	(first, second) = ([], [])
	s = input()
	for j in range(len(s)):
		if s[j] in second:
			pass
		elif s[j] in first:
			first.remove(s[j])
			second.append(s[j])
		else:
			first.append(s[j])
	ans.append((len(first) + len(second) * 2) // 2)
print(*ans, sep='\n')


t = int(input())
for i in range(t):
	s = input()
	d = {}
	c = 0
	for i in s:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	for i in d:
		if d[i] > 2:
			c = c + d[i] - 2
	print((len(s) - c) // 2)


import math
import sys
from collections import *
from bisect import bisect_left, bisect_right
for _ in range(int(input())):
	n = input()
	d = {}
	for i in n:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	l = list(d.values())
	l.sort(reverse=True)
	i = 0
	j = 1
	cur = l[i]
	r = 0
	g = 0
	for i in range(len(l)):
		if l[i] >= 2:
			r += 1
			g += 1
		if l[i] == 1:
			if r < g:
				r += 1
			else:
				g += 1
	if len(n) == 1:
		print(0)
	else:
		print(min(r, g))


t = int(input())
for _ in range(t):
	letters = [0 for _ in range(26)]
	s = input()
	for i in range(len(s)):
		letters[ord(s[i]) - 97] += 1
	count = 0
	ones = 0
	for i in range(26):
		if letters[i] == 1:
			ones += 1
		if letters[i] >= 2:
			count += 1
	count += ones // 2
	print(count)


from collections import Counter
cases = int(input())
for _ in range(cases):
	s = input()
	count = Counter(s)
	c = []
	for v in count.values():
		if v > 2:
			c.append(2)
		else:
			c.append(v)
	colors = int(sum(c) / 2)
	print(colors)


t = int(input())
for _ in range(t):
	s = input()
	map = {}
	for symbol in s:
		if symbol not in map:
			map[symbol] = 1
		else:
			map[symbol] += 1
	dif = 0
	same = 0
	same_n = 0
	for symbol in map:
		if map[symbol] == 1:
			dif += 1
		else:
			same += map[symbol]
			same_n += 1
	x = same - same_n * 2
	print((len(s) - x) // 2)


import math

def solve(s):
	hashm = {}
	if len(s) < 2:
		return 0
	for i in range(len(s)):
		try:
			hashm[s[i]] += 1
		except:
			hashm[s[i]] = 1
	count = 0
	for i in hashm.keys():
		count += min(2, hashm[i])
	return count // 2
t = int(input())
for i in range(t):
	s = input()
	r = solve(s)
	print(r)


import sys, math
inf = math.inf
input = sys.stdin.readline
a = int(input())
for _ in range(a):
	qr = input().strip()
	st = [0] * 30
	cnt = 0
	scnt = 0
	p = len(qr)
	for i in range(p):
		ty = ord(qr[i]) - 96
		if st[ty] == 0:
			scnt += 1
		st[ty] += 1
		if st[ty] == 2:
			cnt += 1
	print((scnt - cnt) // 2 + cnt)


for _ in range(int(input())):
	s = list(input())
	s.sort()
	r = []
	g = []
	f = 0
	for c in s:
		if c in r and c in g:
			continue
		elif c in r:
			g.append(c)
			continue
		elif c in g:
			r.append(c)
		elif len(r) <= len(g):
			r.append(c)
			f = 1
		else:
			g.append(c)
			f = 0
	print(min(len(r), len(g)))


t = int(input())

def q(l):
	l.sort()
	n = len(l)
	l1 = [0]
	s = 1
	ind = 0
	for i in range(n - 1):
		if l[i] == l[i + 1]:
			s += 1
		else:
			l1.append(s - sum(l1))
			ind += 1
			s += 1
	l1.append(n - sum(l1))
	return l1

def h(l1):
	sin = 0
	mult = 0
	for val in l1:
		if val == 1:
			sin += 1
		elif val > 1:
			mult += 1
	return sin // 2 + mult
for i in range(t):
	s = input()
	l = list(s)
	print(h(q(l)))


def solve():
	for i in range(int(input())):
		s = input()
		mult = set()
		solo = set()
		for c in s:
			if c in mult:
				continue
			elif c in solo:
				mult.add(c)
			else:
				solo.add(c)
		print(len(mult) + (len(solo) - len(mult)) // 2)
solve()


ans = []
for _ in range(int(input())):
	(once, more) = (set(), set())
	lone = pair = 0
	for i in input():
		if i in more:
			continue
		elif i in once:
			more.add(i)
			lone -= 1
			pair += 1
		else:
			once.add(i)
			lone += 1
	ans.append(lone // 2 + pair)
print('\n'.join(map(str, ans)))


from collections import Counter

def wonderfulcoloring(n):
	letterCounter = Counter(n)
	numUnique = 0
	numMore = 0
	for (letter, num) in letterCounter.items():
		if num > 1:
			numMore += 1
		elif num == 1:
			numUnique += 1
	print(numUnique // 2 + numMore)
t = int(input())
for i in range(t):
	n = input()
	wonderfulcoloring(n)


t = int(input())
for _ in range(t):
	a = list(input())
	l = len(a)
	c = 1
	h = 'abcdefghijklmnopqrstuvwxyz'
	g = [0 for _ in range(26)]
	for i in a:
		w = h.find(i)
		g[w] += 1
	y = 0
	for i in g:
		if i > 2:
			y += i - 2
	print((l - y) // 2)


import sys
pl = 1
sys.setrecursionlimit(10 ** 5)
if pl:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('outpt.txt', 'w')

def li():
	return [int(xxx) for xxx in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def ff():
	sys.stdout.flush()

def google(tc, *ans):
	print('Case #' + str(tc) + ':', *ans)
t = fi()
f = t

def check(a):
	c = 0
	for i in range(n):
		if a[i] != b[i]:
			c += 1
	return c
while t > 0:
	t -= 1
	s = si()
	n = len(s)
	d = {}
	c = f = 0
	for i in s:
		d[i] = d.get(i, 0) + 1
	for i in d:
		if d[i] > 1:
			c += 1
		else:
			f += 1
	print(c + f // 2)


for i in range(int(input())):
	a = str(input())
	g = 0
	r = 0
	l = [-1 for i in range(len(a))]
	p = []
	for i in range(len(a)):
		if a.count(a[i]) > 1 and a[i] not in p:
			l[i] = 0
			p.append(a[i])
			r += 1
		elif a[i] in p:
			if p.count(a[i]) == 1:
				l[i] = 1
				p.append(a[i])
				g += 1
			else:
				l[i] = 2
	for i in range(len(a)):
		if l[i] == -1:
			if r > g:
				g += 1
			elif g > r:
				r += 1
			else:
				g += 1
	print(min(r, g))


import sys, os, io
from sys import stdin
import math
from collections import defaultdict
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		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')
alphabets = list('abcdefghijklmnopqrstuvwxyz')
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieveForSmallestPrimeFactor():
	MAXN = 100001
	spf = [0 for i in range(MAXN)]
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, math.ceil(math.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
	return spf

def getPrimeFactorizationLOGN(x):
	spf = sieveForSmallestPrimeFactor()
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def si():
	return input()

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')

def solve():
	s = si()
	d = defaultdict(lambda : 0)
	for i in s:
		d[i] += 1
	k = 0
	for i in d:
		if d[i] > 1:
			k += 1
			d[i] = 0
	cnt = 0
	for i in d:
		if d[i] > 0:
			cnt += 1
	print(k + cnt // 2)
t = 1
t = ii()
for _ in range(t):
	solve()


from collections import Counter
for _ in range(int(input())):
	s = input()
	n = len(s)
	c = Counter(s)
	cnt = 0
	for i in set(s):
		if c[i] >= 3:
			cnt += c[i] - 2
	ans = (n - cnt) // 2
	print(ans)


t = int(input())
for _ in range(t):
	s = input()
	dic = {}
	count = 0
	count1 = 0
	for i in s:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
	for j in dic:
		if dic[j] == 1:
			count1 += 1
		else:
			count += 1
	print(count + count1 // 2)


nos_of_cases = int(input())
for _ in range(nos_of_cases):
	str = input()
	freq = {}
	for ch in str:
		if ch in freq:
			freq[ch] += 1
		else:
			freq[ch] = 1
	no1 = 0
	no2 = 0
	for i in freq:
		if freq[i] == 1:
			no1 += 1
		else:
			no2 += 1
	print(no1 // 2 + no2)


for t in range(int(input())):
	s = input()
	freq = {}
	if len(s) <= 1:
		print(0)
		continue
	for i in s:
		if i not in freq:
			freq[i] = 1
		else:
			freq[i] += 1
	ans = 0
	count = 0
	for i in freq:
		if freq[i] > 1:
			ans += 1
		else:
			count += 1
	ans += count // 2
	print(ans)


for _ in range(int(input())):
	s = input()
	d = {}
	for i in s:
		try:
			if d[i]:
				d[i] += 1
		except:
			d[i] = 1
	ans = 0
	for (k, v) in d.items():
		if v == 1:
			ans += 0.5
		else:
			ans += 1
	print(int(ans))


for _ in range(0, int(input())):
	a = input()
	l = []
	for i in set(a):
		l.append(a.count(i))
	t = 0
	for i in range(0, len(l)):
		if l[i] >= 3:
			t += 1
		elif l[i] % 2 == 0:
			t += l[i] // 2
		elif l[i] > 1 and l[i] % 2 == 1:
			t += l[i] // 2
			l[i] = l[i] % 2
	print(t + l.count(1) // 2)


import math
for _ in range(int(input())):
	i = input()
	a = [0] * 26
	s = 0
	sum = 0
	for q in i:
		a[ord(q) - 97] += 1
	for w in a:
		if w > 1:
			sum += 1
		elif w == 1:
			s += 1
	print(sum + s // 2)


for _ in range(int(input())):
	i = input()
	print(sum((min(2, c) for c in map(i.count, set(i)))) // 2)


n = int(input())
for _ in range(n):
	s = input()
	l = len(s)
	d = {}
	for i in s:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	for i in d:
		if d[i] > 2:
			l = l - (d[i] - 2)
	print(l // 2)


def solve():
	dic = {}
	k = 0
	z = 0
	s = input()
	for symbol in s:
		if symbol not in dic:
			dic[symbol] = 1
		else:
			dic[symbol] += 1
	for key in dic:
		if dic[key] == 1:
			if k > z:
				z += 1
			else:
				k += 1
		else:
			k += 1
			z += 1
	print(min(k, z))
n = int(input())
for _ in range(n):
	solve()


t = int(input())
while t:
	s = input()
	d = {}
	dt = {}
	for i in s:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	dt[10] = 0
	dt[1] = 0
	for i in d:
		if d[i] > 1:
			dt[10] += 1
		if d[i] == 1:
			dt[1] += 1
	ans = dt[10] + dt[1] // 2
	print(ans)
	t -= 1


for i in range(int(input())):
	s = input()
	(g, r) = (0, 0)
	for i in set(s):
		if s.count(i) >= 2:
			g += 1
			r += 1
		elif g > r:
			r += 1
		else:
			g += 1
	print(min(g, r))


t = int(input())
for _ in range(t):
	s = input()
	setS = set(s)
	k = 0
	for i in setS:
		x = s.count(i)
		if x > 1:
			k += 1
			s = s.replace(i, '')
	k += len(s) // 2
	print(k)


T = int(input())
for i in range(T):
	a = input()
	b = set(a)
	lst = []
	for i in b:
		lst.append(a.count(i))
	cnt1 = lst.count(1)
	cnt2 = len(lst) - cnt1
	print(cnt1 // 2 + cnt2)


n = int(input())
for i in range(n):
	s = input()
	s1 = set(s)
	(l, m) = ([], [])
	(c, x) = (0, 0)
	for i in s1:
		if s.count(i) == 1:
			x += 1
		else:
			c += 1
	print(x // 2 + c)


from collections import defaultdict
for i in range(int(input())):
	a = input()
	b = defaultdict(int)
	for i in a:
		b[i] += 1
		if b[i] > 2:
			b[i] = 2
	cnt = sum(b.values()) // 2
	print(cnt)


for _ in range(int(input())):
	s = input()
	d = {}
	for i in s:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	l = len(d)
	ans = 0
	for i in d:
		if d[i] >= 2:
			l = l - 1
			ans = ans + 1
	ans = ans + l // 2
	print(ans)


t = int(input())
for k in range(t):
	s = input()
	dic_s = {}
	for let in s:
		dic_s[let] = dic_s.get(let, 0) + 1
	cnt = 0
	for num in dic_s.values():
		if num > 1:
			cnt += 1
		else:
			cnt += 0.5
	print(int(cnt))


from collections import Counter, defaultdict

def solve(s):
	ctr = Counter(s)
	rc = defaultdict(int)
	for c in ctr.values():
		rc[c] += 1
	out = 0
	for c in rc:
		if c == 1:
			out += rc[c] // 2
		else:
			out += rc[c]
	return out

def main():
	p = int(input())
	for i in range(p):
		s = input()
		k = solve(s)
		print(f'{k}')
main()


import collections
for _ in range(int(input())):
	s = input()
	dic = dict(collections.Counter(s))
	countR = 0
	countG = 0
	curr = 'R'
	for key in dic:
		if dic[key] >= 2:
			countR += 1
			countG += 1
		elif dic[key] == 1:
			if curr == 'R':
				countG += 1
				curr = 'G'
			elif curr == 'G':
				countR += 1
				curr = 'R'
	print(min(countR, countG))


def main():
	for i in range(int(input())):
		s = input()
		d = {}
		for j in range(len(s)):
			try:
				d[s[j]] += 1
			except:
				d[s[j]] = 1
		k = 0
		for i in d.values():
			if i == 1:
				k += 1
			if i >= 2:
				k += 2
		print(k // 2)
main()


from sys import stdin, stdout
final_ans = ''
for _ in range(int(stdin.readline())):
	string = stdin.readline()
	ans = 0.0
	cnt_letter = [0] * 26
	for letter in string:
		if ord(letter) - 97 >= 0:
			cnt_letter[ord(letter) - 97] += 1
	for letter in range(26):
		if cnt_letter[letter] >= 2:
			ans += 1.0
		elif cnt_letter[letter] == 1:
			ans += 0.5
	final_ans += str(int(ans)) + '\n'
stdout.write(final_ans)


from sys import stdin, stdout
from collections import Counter

def main():
	for _ in range(int(input())):
		s = input()
		c = Counter(s)
		r = 0
		r1 = 0
		for (v, i) in c.items():
			if i == 1:
				r += 1
			else:
				r1 += 1
		print(r1 + r // 2)
main()


for _ in range(int(input())):
	s = input()
	dt = {}
	c = 0
	l = len(s)
	for i in s:
		if i in dt:
			dt[i] += 1
		else:
			dt[i] = 1
	for i in dt:
		if dt[i] >= 3:
			c += 1
			l -= dt[i]
	c += l // 2
	print(c)


n = int(input())
l = []
for i in range(n):
	l.append(input())

def wonderful(a):
	l1 = []
	for i in a:
		if l1.count(i) == 0:
			l1.append(i)
	count = 0
	for i in l1:
		if a.count(i) >= 2:
			count += 2
		if a.count(i) == 1:
			count += 1
	if count % 2 == 0:
		return count // 2
	elif count % 2 == 1:
		return (count - 1) // 2
for i in l:
	print(wonderful(i))


t = int(input())
while t > 0:
	x = input()
	y = len(x)
	count = 0
	sum = 0
	for i in range(0, len(x)):
		if x.count(x[i]) > 1 and x[i] != ' ':
			x = x.replace(x[i], ' ')
			count += 1
	for i in x:
		if i != ' ':
			sum = sum + 1
	print(count + int(sum / 2))
	t -= 1


def ls():
	return list(map(int, input().split()))

def ip():
	return int(input())
t = ip()
for _ in range(t):
	s = tuple(input())
	set_s = set(s)
	single = 0
	double = 0
	for i in set_s:
		if s.count(i) == 1:
			single += 1
		else:
			double += 1
	print(double + single // 2)


t = int(input())
for u in range(t):
	(dem, cnt, s) = (0, [0] * 256, input())
	for x in s:
		cnt[ord(x)] += 1
	for x in cnt:
		dem += max(0, x - 2)
	print((len(s) - dem) // 2)


for i in range(int(input())):
	mylist = list(input())
	j = 0
	while j < len(mylist):
		if mylist.count(mylist[j]) > 2:
			mylist.pop(j)
			j -= 1
		j += 1
	print(len(mylist) // 2)


for _ in range(int(input())):
	d = {}
	for i in input():
		d[i] = d.get(i, 0) + 1
	c = 0
	m = 0
	for (i, j) in d.items():
		if j > 1:
			c += 1
		elif j == 1:
			m += 1
	print(c + m // 2)


tests = int(input())
for _ in range(tests):
	s = input()
	red = []
	green = []
	for c in set(s):
		k = s.count(c)
		if k >= 2:
			red.append(c)
			green.append(c)
		elif len(red) < len(green):
			red.append(c)
		else:
			green.append(c)
	print(len(red))


import math
t = int(input())
for tc in range(t):
	n = str(input())
	unique = set(n)
	set_more = 0
	l = len(n)
	tot = 0
	for i in unique:
		occur = n.count(i)
		if occur >= 2:
			tot += 1
			set_more += 1
	l2 = len(unique) - set_more
	if l2 % 2 == 0:
		tot += int(l2 / 2)
	else:
		tot += int(l2 - 1) / 2
	print(int(tot))


t = int(input())
for j in range(t):
	letters = {}
	s = input()
	s = list(s)
	if len(s) < 2:
		print(0)
	else:
		for i in s:
			if i not in letters:
				letters[i] = 1
			elif letters[i] < 2:
				letters[i] += 1
		x = letters.values()
		print(int(sum(x) / 2))


import sys
tc_num = int(sys.stdin.readline())
for _ in range(tc_num):
	string1 = sys.stdin.readline().strip()
	alpha_nums = [0] * 26
	len1 = len(string1)
	for i in range(len1):
		if alpha_nums[ord(string1[i]) - ord('a')] <= 1:
			alpha_nums[ord(string1[i]) - ord('a')] += 1
		else:
			pass
	print(sum(alpha_nums) // 2)


for _ in range(int(input())):
	s = input()
	ile = 0
	for a in set(s):
		ile = ile + 1 if s.count(a) == 1 else ile + 2
	print(ile // 2)


from bisect import insort, bisect_right, bisect_left
from sys import stdout, stdin, setrecursionlimit
from heapq import heappush, heappop, heapify
from io import BytesIO, IOBase
from collections import *
from itertools import *
from random import *
from string import *
from queue import *
from math import *
from re import *
from os import *

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		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')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))
(graph, mod, szzz) = ({}, 10 ** 9 + 7, lambda : sorted(zzz()))

def getStr():
	return input()

def getInt():
	return int(input())

def listStr():
	return list(input())

def getStrs():
	return input().split()

def isInt(s):
	return '0' <= s[0] <= '9'

def input():
	return stdin.readline().strip()

def zzz():
	return [int(i) for i in input().split()]

def output(answer, end='\n'):
	stdout.write(str(answer) + end)

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def getPrimes(N=10 ** 5):
	SN = int(sqrt(N))
	sieve = [i for i in range(N + 1)]
	sieve[1] = 0
	for i in sieve:
		if i > SN:
			break
		if i == 0:
			continue
		for j in range(2 * i, N + 1, i):
			sieve[j] = 0
	prime = [i for i in range(N + 1) if sieve[i] != 0]
	return prime

def primeFactor(n, prime=getPrimes()):
	lst = []
	mx = int(sqrt(n)) + 1
	for i in prime:
		if i > mx:
			break
		while n % i == 0:
			lst.append(i)
			n //= i
	if n > 1:
		lst.append(n)
	return lst
dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
daysInMounth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
num = getInt()
for _ in range(num):
	lst = [0] * 26
	arr = getStr()
	for i in arr:
		lst[ord(i) - 97] += 1
	two = 0
	one = 0
	for i in lst:
		if i >= 2:
			two += 1
		elif i == 1:
			one += 1
	print(two + one // 2)


def solve(s):
	k = 0
	hash = {}
	for c in s:
		if c not in hash:
			hash[c] = 1
			k += 1
		else:
			hash[c] += 1
			if hash[c] < 3:
				k += 1
	return k // 2
t = int(input())
while t:
	s = input()
	print(solve(s))
	t -= 1


from collections import Counter
t = int(input())
temp = 0
count = 0
strings = []
for i in range(t):
	temp = input()
	strings.append(temp)
for s in strings:
	count = 0
	for n in Counter(s).values():
		if n > 1:
			count += 2
		elif n == 1:
			count += 1
	print(count // 2)


from collections import Counter

def solve():
	string = input()
	counter = Counter(string)
	red = 0
	single_count_char = 0
	for (char, count) in counter.items():
		if count >= 2:
			red += 1
		else:
			single_count_char += 1
	red += single_count_char // 2
	return red
for _ in range(int(input())):
	print(solve())


import sys
cin = int(sys.stdin.readline().strip())
for testcase in range(cin):
	cin1 = sys.stdin.readline().strip()
	d = {}
	r = 0
	g = 0
	for i in cin1:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	for i in d:
		if d[i] >= 2:
			r += 1
			g += 1
		else:
			r += 1
	print((r + g) // 2)


def coloring(s):
	l = list(set(s))
	unique_letters = 0
	repeated_letters = 0
	for i in range(len(l)):
		if s.count(l[i]) == 1:
			unique_letters += 1
		else:
			repeated_letters += 1
	return repeated_letters + unique_letters // 2
for _ in range(int(input())):
	s = str(input())
	print(coloring(s))


import math
from collections import Counter
N = int(input())
for _ in range(N):
	s = input()
	more2 = len([x for x in Counter(s).values() if x >= 2])
	eq1 = len([x for x in Counter(s).values() if x == 1])
	print(more2 + math.floor(eq1 / 2))


tests = int(input())
arr = []
out = []
for _ in range(tests):
	arr.append(input())
for x in range(len(arr)):
	used = []
	used2 = []
	r = 0
	g = 0
	for y in range(len(arr[x])):
		if arr[x][y] not in used:
			used.append(arr[x][y])
			r += 1
		elif arr[x][y] not in used2:
			used2.append(arr[x][y])
			g += 1
	if abs(r - g) > 1:
		out.append((r + g) // 2)
	elif r > g:
		out.append(r - 1)
	else:
		out.append(r)
for a in out:
	print(a)


for _ in range(int(input())):
	l = list(input())
	s = set(l)
	red = 0
	gr = 0
	c = 0
	for x in s:
		n = l.count(x)
		if n >= 2:
			red = red + 1
		if n == 1:
			c = c + 1
	if c % 2 == 0:
		red = red + c // 2
	else:
		red = red + (c - 1) // 2
	print(red)


from collections import Counter
for i in range(int(input())):
	string = input()
	counter = Counter(string)
	score = 0
	count = 0
	for (a, b) in counter.items():
		if b >= 2:
			score += 1
		elif b == 1:
			count += 1
	print(score + count // 2)


from sys import *
from math import floor
input = lambda : stdin.readline()
int_arr = lambda : list(map(int, stdin.readline().strip().split()))
str_arr = lambda : list(map(str, stdin.readline().split()))
get_str = lambda : map(str, stdin.readline().strip().split())
get_int = lambda : map(int, stdin.readline().strip().split())
get_float = lambda : map(float, stdin.readline().strip().split())
mod = 1000000007
setrecursionlimit(1000)
for _ in range(int(input())):
	s = str(input())[:-1]
	a = []
	b = []
	(ct, ct1) = (0, 0)
	for i in range(len(s)):
		if s[i] not in a:
			ct += 1
			a.append(s[i])
		elif s[i] not in b:
			ct1 += 1
			b.append(s[i])
	diff = (ct - ct1) // 2
	print(diff + ct1)


import sys
input = sys.stdin.readline
from collections import defaultdict

def main():
	S = input().strip()
	cnt = [0] * 26
	for s in S:
		cnt[ord(s) - 97] += 1
	ans = 0
	for c in cnt:
		ans += min(c, 2)
	print(ans // 2)
for _ in range(int(input())):
	main()


n = int(input())
for i in range(n):
	a = input()
	b = dict()
	c = 0
	for j in a:
		if j not in b:
			b[j] = 1
		else:
			if b[j] >= 2:
				c += 1
			b[j] += 1
	print(int((len(a) - c) / 2))


from collections import Counter
for _ in range(int(input())):
	s = input()
	red = 0
	is_red_turn = False
	counts = Counter(s)
	for letter in counts:
		if counts[letter] >= 2:
			red += 1
		elif is_red_turn:
			is_red_turn = False
			red += 1
		else:
			is_red_turn = True
	print(red)


t = int(input())
for _ in range(t):
	s = input()
	dic = {}
	for i in s:
		if i in dic:
			dic[i] += 1
		elif i not in dic:
			dic[i] = 1
	red = 0
	green = 0
	c = 0
	if len(dic) == 1 and len(s) != 1:
		print(1)
		continue
	for (i, j) in dic.items():
		if j >= 2:
			red += 1
			green += 1
			c += j - 2
	r = len(s) - (red + green) - c
	r = r // 2
	print(r + red)


n = int(input())
for i in range(n):
	k = input()
	s = 'abcdefghijklmnopqrstuvwxyz'
	m = [0] * len(s)
	for j in range(len(k)):
		if m[s.index(k[j])] < 2:
			m[s.index(k[j])] += 1
	ans = sum(m)
	print(ans // 2)


import itertools, os
for _ in itertools.repeat(None, int(input())):
	st = list(input())
	st.sort()
	single = []
	double = []
	for (key, group) in itertools.groupby(st):
		ok = list(group)
		if len(ok) > 1:
			double.append(ok)
		else:
			single.append(ok)
	cnt = len(double) + len(single) // 2
	os.write(1, b'%d\n' % cnt)


import sys

def input():
	return sys.stdin.readline().strip()

def ints():
	return map(int, input().split())
T = int(input())
for _ in range(T):
	s = input()
	count = [0] * 26
	for i in s:
		count[ord(i) - ord('a')] += 1
	t = 0
	for i in count:
		t += min(i, 2)
	print(t // 2)


NUM = int(input())
for T in range(0, NUM):
	cnt1 = cnt2 = 0
	dict = {}
	str = input()
	for i in range(0, len(str)):
		sub = str[i]
		dict[sub] = dict.get(sub, 0) + 1
	for (x, y) in dict.items():
		cnt1 += y == 1
		cnt2 += y >= 2
	print(cnt2 + cnt1 // 2)


total = int(input())

def res(word):
	result = 0
	s = 0
	for i in 'abcdefghijklmnopqrstuvwxyz':
		if word.count(i) > 1:
			result += 1
		elif word.count(i) == 1:
			s += 1
	return result + s // 2
for i in range(total):
	print(res(input()))


class solution:

	def __init__(self, s):
		self.s = s
		self.answer = 0

	def caluclation(self):
		d = {}
		for i in s:
			if i not in d:
				d[i] = 1
			elif d[i] > 1:
				pass
			else:
				d[i] += 1
		sum_all = 0
		for i in d:
			sum_all += d[i]
		if sum_all % 2 != 0:
			sum_all -= 1
		self.answer = int(sum_all / 2)
t = int(input())
for _ in range(t):
	s = input()
	root = solution(s)
	root.caluclation()
	print(root.answer)


for i in range(int(input())):
	x = str(input())
	ans = 0
	t = 0
	d = {}
	for j in x:
		if d.get(j) != None:
			d[j] += 1
		else:
			d[j] = 1
	for f in d:
		if d[f] >= 2:
			ans += 1
		elif d[f] == 1:
			t += 1
	ans += t // 2
	print(ans)


t = int(input())
for i in range(0, t):
	s = str(input())
	c = list(set(s))
	diff = len(s) - len(c)
	n = len(s)
	numof3 = 0
	arr = []
	for z in range(0, len(c)):
		arr.append(c[z])
	for j in range(0, len(arr)):
		count = s.count(arr[j])
		if count >= 3:
			numof3 += 1
		if count > 3:
			n = n - (count - 3)
	print(numof3 + (n - numof3 * 3) // 2)


for i in range(int(input())):
	x = input()
	a = {}
	for c in x:
		if c in a:
			a[c] += 1
		else:
			a[c] = 1
	(k, ans) = (0, 0)
	for c in a:
		if a[c] > 1:
			ans += 1
		else:
			k += 1
	print(ans + k // 2)


from collections import Counter
for _ in range(int(input())):
	s = input()
	c = Counter(s)
	li1 = 0
	li2 = 0
	for (x, y) in c.items():
		if y == 1:
			li1 += 1
		else:
			li2 += 1
	res = li2 + li1 // 2
	print(res)


from collections import Counter

def digits(s):
	hmap = dict(Counter(s))
	ans = 0
	singles = 0
	for (k, v) in hmap.items():
		if v >= 2:
			ans += 1
		if v == 1:
			singles += 1
	ans += singles // 2
	return ans
for _ in range(int(input())):
	s = input()
	print(digits(s))


from collections import defaultdict
for _ in range(int(input())):
	s = input()
	total = 0
	check = defaultdict(int)
	for c in s:
		check[c] += 1
	for (k, v) in check.items():
		total += min(2, v)
	print(total // 2)


t = int(input())
while t > 0:
	t -= 1
	s = input()
	m = {}
	for i in s:
		m[i] = m.get(i, 0) + 1
	n = len(m)
	l = 0
	for i in m:
		if m[i] >= 2:
			l += 1
	rem = n - l
	if rem % 2 == 0:
		l += rem // 2
	else:
		l += (rem - 1) // 2
	print(l)


for _ in range(int(input())):
	s = input()
	d = {}
	count = 0
	for i in range(len(s)):
		if s[i] not in d.keys():
			d[s[i]] = 1
		else:
			if d[s[i]] == 1:
				count += 1
			d[s[i]] += 1
	n = len(d)
	k = n - count
	print(count + k // 2)


def sol():
	s = input()
	n = len(s)
	cnt = [0] * 26
	for i in range(n):
		cnt[ord(s[i]) - 97] += 1
	c1 = 0
	c2 = 0
	for i in range(26):
		c1 += cnt[i] == 1
		c2 += cnt[i] > 1
	print(c2 + c1 // 2)
t = int(input())
for i in range(t):
	sol()


for t in range(int(input())):
	s = input()
	a = [0 for i in range(27)]
	for i in s:
		a[ord(i) - 97] += 1
	p = 0
	q = 0
	for i in a:
		if i > 1:
			p += 1
		elif i == 1:
			q += 1
	print(p + q // 2)


def cf_734B(string: str):
	counts = {}
	for c in string:
		counts[c] = counts.get(c, 0) + 1
	extras = answer = 0
	for val in counts.values():
		if val > 1:
			answer += 1
		else:
			extras += 1
	return answer + extras // 2
for _ in range(int(input())):
	print(cf_734B(input()))


def main():
	alpha = 'abcdefghijklmnopqrstuvwxyz'
	ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	inf = 1e+17
	mod = 10 ** 9 + 7

	def factorial(n):
		f = 1
		for i in range(1, n + 1):
			f = f * i % mod
		return f

	def ncr(n, r):
		num = den = 1
		for i in range(r):
			num = num * (n - i) % mod
			den = den * (i + 1) % mod
		return num * pow(den, mod - 2, mod) % mod

	def solve(s):
		cnt = dict()
		for i in range(26):
			cnt[alpha[i]] = 0
		for i in range(len(s)):
			cnt[s[i]] += 1
		answer = 0
		for i in range(26):
			if cnt[alpha[i]] > 2:
				answer += 2
			else:
				answer += cnt[alpha[i]]
		return answer // 2
		pass
	t = int(input())
	ans = []
	for _ in range(t):
		s = input()[:-1]
		ans.append(solve(s))
	for answer in ans:
		print(answer)
import sys, threading
import bisect
import math
import itertools
from sys import stdout
import heapq
from queue import PriorityQueue
input = sys.stdin.readline
thread = threading.Thread(target=main)
thread.start()
thread.join()


result = []
for i in range(int(input())):
	s = input()
	count = 0
	thua = 0
	test = []
	for x in s:
		if x not in test:
			if s.count(x) >= 2:
				count += 1
			if s.count(x) == 1:
				thua += 1
			test.append(x)
	count += int(thua / 2)
	result.append(count)
for r in result:
	print(r)


def occurence(array):
	array.sort()
	l = len(array)
	i = 0
	occur = []
	while i < l - 1:
		if array[i] != array[i + 1]:
			occur.append(1)
			i += 1
		else:
			j = 1
			while i + j < l and array[i + j] == array[i]:
				j += 1
			else:
				i += j
				occur.append(j)
	else:
		if array[-1] != array[-2]:
			occur.append(1)
		return occur
t = int(input())
for test in range(t):
	string = input()
	if len(string) < 2:
		print(0)
	else:
		List = []
		for item in string:
			List.append(item)
		List2 = occurence(List)
		s = 0
		s1 = 0
		for item in List2:
			if item >= 2:
				s += 1
			else:
				s1 += 1
		s += s1 // 2
		print(s)


t = int(input())
for _ in range(t):
	s = list(input().strip())
	n = len(s)
	count = dict()
	for i in s:
		count[i] = count.get(i, -2) + 1
	three = 0
	for i in count.values():
		if i > 0:
			three += i
	print((n - three) // 2)


from collections import Counter
t = int(input())

def solve(s):
	c = Counter(s)
	result1 = 0
	result2 = 0
	for (x, count) in c.items():
		if count >= 2:
			result1 += 1
		else:
			result2 += 1
	return result1 + result2 // 2
for test in range(t):
	s = input()
	print(solve(s))


n = int(input())
for i in range(n):
	dict_ = {}
	answer = 0
	x = input()
	for ch in x:
		if ch in dict_:
			if dict_[ch] < 2:
				dict_[ch] += 1
				answer += 1
		else:
			dict_[ch] = 1
			answer += 1
	print(answer // 2)


from typing import Counter
for _ in range(int(input())):
	s = input()
	d = Counter(s)
	for i in d:
		temp = min(2, d[i])
		d[i] = temp
	ans = sum(list(d.values())) // 2
	print(ans)


import math
import heapq
from collections import Counter
t = int(input())
for _ in range(t):
	s = input()
	alp = Counter(list(s))
	c = 0
	for i in alp:
		if alp[i] >= 2:
			c += 2
		else:
			c += 1
	print(c // 2)


t = int(input())
otv = list()
for i in range(t):
	n = input()
	sp = list()
	for j in n:
		if sp.count(j) < 2:
			sp.append(j)
	otv.append(len(sp) // 2)
for i in otv:
	print(i)


import math
t = int(input())
for _ in range(t):
	s = input()
	red = []
	green = []
	for l in s:
		if l not in red:
			red.append(l)
		elif l not in green:
			green.append(l)
	print((len(red) + len(green)) // 2)


def solve():
	s = input()
	a = [0] * 26
	answer = 0
	k = 0
	for i in range(26):
		a[i] = s.count(chr(i + 97))
		if a[i] >= 2:
			answer += 1
		if a[i] == 1:
			k += 1
	answer += k // 2
	print(answer)
for t in range(int(input())):
	solve()


t = int(input())
for _ in range(t):
	n = input()
	d = {}
	for i in n:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	l = list(d.values())
	c = 0
	ct = 0
	for i in l:
		if i >= 2:
			c = c + 1
		else:
			ct = ct + 1
	c = c + ct // 2
	print(c)


t = int(input())
for _ in range(t):
	s = input()
	h = {}
	for each in s:
		if each in h:
			h[each] += 1
		else:
			h[each] = 1
	a = 0
	b = 0
	for each in h:
		if h[each] > 1:
			a += 1
		elif h[each] == 1:
			b += 1
	print(a + b // 2)


t = int(input())
for case in range(t):
	s = input()
	n = len(s)
	freq = {}
	for i in range(n):
		if s[i] not in freq:
			freq[s[i]] = 0
		freq[s[i]] += 1
	aux = 0
	ans = 0
	for (k, v) in freq.items():
		if v > 1:
			ans += 1
		else:
			aux += 1
	ans += aux // 2
	print(ans)


d = int(input())
for p in range(0, d):
	a = input()
	dicnry = {}
	for i in a:
		try:
			dicnry[i] += 1
		except:
			dicnry[i] = 1
	fout = list(dicnry.values())
	x = 0
	l = 0
	for i in fout:
		if i == 1:
			x = x + 1
		else:
			l = l + 1
	print(x // 2 + l)


t = int(input())
for i in range(t):
	text = input()
	dict_ = {}
	color = 0
	for ch in text:
		if ch not in dict_:
			dict_[ch] = 1
		else:
			dict_[ch] += 1
	for ch in dict_:
		if dict_[ch] == 1:
			color += 0.5
		elif dict_[ch] == 2:
			color += 1
		else:
			color += 1
	print(int(color))


def main():
	for i in range(num()):
		solve()

def solve():
	s = input()
	d = dict()
	for i in range(len(s)):
		if s[i] not in d:
			d[s[i]] = 1
		else:
			d[s[i]] += 1
	ans = len(s)
	for i in d:
		if d[i] > 2:
			ans -= d[i] - 2
	if ans % 2 == 0:
		print(int(ans / 2))
	else:
		print(int((ans - 1) / 2))
import itertools
import bisect, math
import copy
import fractions

def s(e):
	return sum(e)

def l(e):
	return len(e)

def num():
	return int(input())

def array():
	return list(map(int, input().split()))

def pair():
	return map(int, input().split())

def p(x='', end='\n'):
	return print(x, end=end)

def sort(a):
	return sorted(a)

def fpair(x):
	return str(fractions.Fraction(x)).split('/')

def parray(a):
	for i in a:
		p(i, end=' ')
	p()
main()


import sys
import os
import math
from io import BytesIO, IOBase
from collections import defaultdict, Counter, deque
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	s = input()
	c = Counter(s)
	ans = 0
	flag = 0
	for j in c:
		if c[j] >= 2:
			ans += 1
		elif flag == 0:
			flag = 1
		else:
			flag = 0
			ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	s = input()
	l = [-1] * 26
	c = 0
	for i in range(len(s)):
		x = ord(s[i]) - 97
		if l[x] == -1:
			c += 1
			l[x] = i
		elif l[x] != -2:
			c += 1
			l[x] = -2
	print(c // 2)


import sys
import math

def main():
	numTest: int = int(sys.stdin.readline().split()[0])
	for i in range(0, numTest):
		word = sys.stdin.readline().split()[0]
		chars_in_a_pair = set()
		seen = set()
		unpainted = 0
		for char in word:
			if char in seen and char not in chars_in_a_pair:
				chars_in_a_pair.add(char)
			elif char in seen and char in chars_in_a_pair:
				unpainted += 1
			seen.add(char)
		left = int((len(word) - 2 * len(chars_in_a_pair) - unpainted) / 2)
		print(len(chars_in_a_pair) + left)
main()


from collections import Counter
import math
t = int(input())
for i in range(t):
	s = input()
	d = Counter(s)
	c = 0
	a = 0
	for (k, v) in d.items():
		if v == 1:
			c += 1
		elif v == 2:
			a += 1
		else:
			a += 1
	print(a + math.floor(c / 2))


import sys, io, os, math, bisect, heapq
from collections import Counter, deque, defaultdict
try:
	inp = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
except:
	inp = lambda : sys.stdin.readline().encode()
L = lambda : list(map(int, inp().split()))
I = lambda : int(inp())
S = lambda : inp().strip().decode()
C = lambda : inp().split()

def pr(a):
	print(' '.join(list(map(str, a))))

def solve():
	s = S()
	d = defaultdict(int)
	(x, y) = (0, 0)
	n = len(s)
	for i in s:
		if d[i] < 2:
			x += 1
			d[i] += 1
		else:
			y += 1
	print(x // 2)
for _ in range(I()):
	solve()


for i in range(int(input())):
	s = input()
	n = 0
	for j in 'qwertyuioplkjhgfdsazxcvbnm':
		cou = s.count(j)
		if cou == 1:
			n += 1
		elif cou >= 2:
			n += 2
	print(n // 2)


for _ in range(int(input())):
	st = input()
	dic = {}
	sol = 0
	t = 0
	for elem in st:
		if elem not in dic:
			dic[elem] = 1
		else:
			dic[elem] += 1
	for key in dic.keys():
		if dic[key] >= 2:
			sol += 1
		elif dic[key] == 1:
			t += 1
	sol += t // 2
	if len(dic) == len(st):
		print(len(st) // 2)
	else:
		print(sol)


t = int(input())
for i in range(t):
	a = input()
	ll = dict()
	(red, green) = (0, 0)
	for symb in a:
		try:
			if ll[symb][0] < 2:
				if green <= red:
					green += 1
				else:
					red += 1
				ll[symb][0] += 1
		except Exception:
			if green <= red:
				ll[symb] = [1, 'g']
				green += 1
			else:
				ll[symb] = [1, 'r']
				red += 1
	print(min(red, green))


for _ in range(int(input())):
	s = input()
	l = [0] * 27
	r = 0
	g = 0
	for i in s:
		a = 97 - ord(i)
		if l[a] < 2:
			l[a] += 1
			if r == g:
				r += 1
			else:
				g += 1
	print(min(r, g))


for _ in range(int(input())):
	s = input()
	num = {i: s.count(i) for i in s}
	res = 0
	for f in num.values():
		if f <= 2:
			res += f
		else:
			res += 2
	print(res // 2)


from collections import Counter

def main():
	ncases = int(input())

	def solve(s):
		cntr = Counter(s)
		ones = 0
		morethanones = 0
		for (k, v) in cntr.items():
			if v == 1:
				ones += 1
			else:
				morethanones += 1
		c = 0
		c += ones // 2
		c += morethanones
		return c
	while ncases:
		s = input()
		print(solve(s))
		ncases -= 1
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from types import GeneratorType

def bootstrap(func, stack=[]):

	def wrapped_function(*args, **kwargs):
		if stack:
			return func(*args, **kwargs)
		else:
			call = func(*args, **kwargs)
			while True:
				if type(call) is GeneratorType:
					stack.append(call)
					call = next(call)
				else:
					stack.pop()
					if not stack:
						break
					call = stack[-1].send(call)
			return call
	return wrapped_function
main()


for i in range(int(input())):
	n = input()
	x = 0
	y = []
	for i in n:
		if i not in y:
			if n.count(i) >= 2:
				x += 2
			else:
				x += 1
		y.append(i)
	print(x // 2)


t = int(input())
for i in range(t):
	s = str(input())
	d = {}
	for j in range(len(s)):
		if s[j] not in d:
			d[s[j]] = 0
		d[s[j]] += 1
	ones = 0
	red = 0
	for symb in d:
		if d[symb] == 1:
			ones += 1
		else:
			red += 1
	print(red + ones // 2)


t = int(input())
for _ in range(t):
	s = input()
	from collections import Counter
	h = dict(Counter(s))
	print(sum((min(x, 2) for x in h.values())) // 2)


from collections import Counter
t = int(input())
while t:
	c = 0
	t -= 1
	s = input()
	a = Counter(s)
	for i in a:
		if a[i] > 2:
			c += 2
		else:
			c += a[i]
	print(c // 2)


t = int(input())
for i in range(t):
	s = input()
	D = {}
	for elem in s:
		if elem not in D:
			D[elem] = 0
		D[elem] += 1
	ans = 0
	cnt = 0
	for key in D:
		if D[key] % 2 == 0:
			ans += 1
		elif D[key] == 1:
			cnt += 1
		else:
			ans += 1
	ans += cnt // 2
	print(ans)


import bisect, collections, copy, heapq, itertools, math, string, sys, queue, time, random
input = lambda : sys.stdin.readline().rstrip()

def I():
	return input()

def IS():
	return input().split()

def II():
	return int(input())

def IIS():
	return map(int, input().split())

def LIIS():
	return list(map(int, input().split()))

def Base_n_to_10(X, n):
	out = 0
	for i in range(1, len(str(X)) + 1):
		out += int(X[-i]) * n ** (i - 1)
	return out

def Base_10_to_n(X, n):
	if X // n:
		return Base_10_to_n(X // n, n) + str(X % n)
	return str(X % n)
INF = 10 ** 18
MOD = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 6)
t = II()
for _ in range(t):
	s = I()
	dic = collections.defaultdict(int)
	for i in s:
		dic[i] += 1
	sm = sum([min(dic[i], 2) for i in dic])
	print(sm // 2)


from collections import Counter as C
for _ in range(int(input())):
	s = list(input())
	arr = list(C(s).values())
	ans = 0
	for i in arr:
		if i > 1:
			ans += 1
		else:
			ans += 0.5
	print(int(ans))


for i in range(int(input())):
	a = [0] * 26
	b = input()
	for i in b:
		a[ord(i) - ord('a')] += 1
	sum = 0
	for i in a:
		if i > 2:
			sum = sum + 2
		else:
			sum = sum + i
	print(sum // 2)


def f(s):
	ans = 0
	d = {}
	for i in s:
		if i in d.keys():
			d[i] += 1
		else:
			d[i] = 1
	sing = 0
	for i in d.keys():
		if d[i] == 1:
			sing += 1
		else:
			ans += 1
	ans += sing // 2
	return ans
num = int(input())
for i in range(num):
	ip = input()
	op = f(ip)
	print(op)


for _ in range(int(input())):
	s = input()
	if len(s) == 1:
		print(0)
		continue
	if len(s) == 2:
		print(1)
		continue
	mx = 0
	for i in set(s):
		mx += min(s.count(i), 2)
	print(mx // 2)


import sys
get = sys.stdin.readline

def main():
	s = str(get()).strip()
	cnt = [0] * 26
	for ch in s:
		cnt[ord(ch) - 97] += 1
	(c1, c2) = (0, 0)
	for x in cnt:
		if x == 1:
			c1 += 1
		if x > 1:
			c2 += 1
	print(c1 // 2 + c2)
for _ in range(int(get())):
	main()


from collections import defaultdict
from sys import stdin
input = stdin.readline
N = int(input())
for _ in range(N):
	s = input().rstrip()
	dic = defaultdict(int)
	for i in s:
		dic[i] += 1
	cnt = 0
	for (key, val) in dic.items():
		if val >= 2:
			cnt += 2
		else:
			cnt += val
	print(cnt // 2)


for _ in range(int(input())):
	n = list(input())
	r = sum((n.count(i) - 2 for i in set(n) if n.count(i) > 2))
	print((len(n) - r) // 2)


def answer(w):
	d = {}
	for ww in w:
		try:
			d[ww] += 1
		except:
			d[ww] = 1
	l = sorted(list(d.values()))[-1::-1]
	return len([k for k in l if k > 1]) + len([k for k in l if k == 1]) // 2
t = int(input())
for _ in range(t):
	print(answer(input()))


t = int(input())
while t:
	s = input()
	hash = [0] * 26
	ans = 0
	r = 0
	for i in range(len(s)):
		p = ord(s[i])
		hash[p - 97] += 1
	for i in range(26):
		if hash[i] >= 2:
			ans += 1
		elif hash[i] == 1:
			r += 1
			if r == 2:
				ans += 1
				r = 0
	print(ans)
	t -= 1


t = int(input())
for i in range(t):
	s = input()
	red = 0
	green = 0
	chet = 0
	s = ['0'] + sorted(s) + ['0']
	for j in range(1, len(s) - 1):
		if s[j - 1] == s[j] and s[j] == s[j + 1]:
			red += 0
		elif s[j] == s[j + 1]:
			red += 1
			green += 1
		elif s[j] != s[j - 1] and s[j] != s[j + 1]:
			chet += 1
	print(red + chet // 2)


n = int(input())
text = ''
list = []
counter = 0
for i in range(n):
	text = input()
	counter = 0
	list = []
	for t in range(len(text)):
		if text[t] not in list:
			list.append(text[t])
			if text.count(text[t]) > 2:
				counter += 2
			else:
				counter += text.count(text[t])
	print(int(counter / 2))


for i in range(int(input())):
	word = input()
	(c1, c2) = (0, 0)
	same = []
	for i in word:
		if i in same:
			continue
		if word.count(i) > 1:
			c2 += 1
			same.append(i)
		else:
			c1 += 1
	print(c1 // 2 + c2)


T = int(input())
for i in range(T):
	d = dict()
	s = input()
	for l in s:
		if l not in d:
			d[l] = 1
		else:
			d[l] += 1
	count1 = 0
	count2 = 0
	for v in d.values():
		if v == 1:
			count1 += 1
		else:
			count2 += 1
	print(int(count1 / 2) + count2)


for _ in range(int(input())):
	s = input()
	l = 0
	if len(s) < 2:
		print(0)
	else:
		b = [0] * 26
		for i in s:
			k = ord(i) - 97
			b[k] += 1
		for i in range(26):
			if b[i] > 2:
				l += 2
			else:
				l += b[i]
		print(l // 2)


t = int(input())
while t > 0:
	WORD = input()
	if len(WORD) == 1:
		print(0)
	else:
		a = []
		x = 0
		y = 0
		for i in WORD:
			if i not in a:
				a.append(i)
		for i in a:
			if WORD.count(i) > 1:
				x += 1
			else:
				y += 1
		print(x + y // 2)
	t -= 1


cases = int(input())
fin = list()
for i in range(cases):
	n = input()
	check = list()
	for j in n:
		if check.count(j) < 2:
			check.append(j)
	fin.append(len(check) // 2)
for i in fin:
	print(i)


from os import path
from io import BytesIO, IOBase
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, Counter, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('0')
file = 1

def ceil(a, b):
	return (a + b - 1) // b

def solve():
	for _ in range(1, ii() + 1):
		s = si()
		ans = 0
		for i in range(26):
			c = s.count(chr(97 + i))
			ans += min(c, 2)
		print(ans // 2)
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


for _ in range(int(input())):
	s = input()
	ls = []
	cnt = []
	sw = False
	ans = 0
	for i in s:
		if i not in ls:
			ls.append(i)
	for i in ls:
		cnt.append(s.count(i))
	for i in cnt:
		if i >= 2:
			ans += 1
		elif sw:
			ans += 1
			sw = False
		else:
			sw = True
	print(ans)


import math
t = int(input())
for i in range(t):
	s = input()
	w = 0
	m = {q: 0 for q in 'qwertyuiopasdfghjklzxcvbnm'}
	for k in s:
		m[k] += 1
		if m[k] <= 2:
			w += 1
	print(math.floor(w / 2))


from collections import Counter
for _ in range(int(input())):
	s = input()
	c = Counter(s)
	a = 0
	b = 0
	for i in c.values():
		if i > 1:
			a += 1
		else:
			b += 1
	if b % 2 != 0:
		b -= 1
	print(a + b // 2)


t = int(input())
for i in range(t):
	d = dict()
	s = input()
	for i in s:
		d[i] = d.get(i, 0) + 1
	count = 0
	sum = 0
	for i in d.values():
		if i >= 2:
			count += 1
		else:
			sum += 1
	print(count + sum // 2)


from collections import Counter
for t in range(int(input())):
	s = input()
	f = Counter(s)
	(r, g) = (0, 0)
	for c in f:
		if f[c] == 1:
			if r <= g:
				r += 1
			else:
				g += 1
		else:
			r += 1
			g += 1
	print(min(r, g))


t = int(input())
while t:
	t = t - 1
	s = input()
	s = sorted(s)
	(r, g) = ([], [])
	for i in range(len(s)):
		if not s[i] in r:
			r.append(s[i])
		elif not s[i] in g:
			g.append(s[i])
	rem = len(r) - len(g)
	if len(r) < len(g):
		print(len(r))
	else:
		print(len(g) + rem // 2)


for idfghjk in range(int(input())):
	s = list(input())
	d = {}
	s.sort()
	for i in s:
		try:
			d[i] += 1
		except:
			d[i] = 1
	l = 0
	r = 0
	x = True
	for i in d.keys():
		if d[i] > 1:
			l += 1
			r += 1
		elif d[i] == 1:
			if x:
				l += 1
				x = False
			else:
				r += 1
				x = True
	print(min(l, r))


for q in range(int(input())):
	string = input()
	k = 0
	ed = 0
	for i in set(string):
		if string.count(i) > 1:
			k += 1
		else:
			ed += 1
	print(k + ed // 2)


n = int(input())
for i in range(n):
	string = input()
	counts = dict()
	red = 0
	green = 0
	for char in string:
		counts[char] = string.count(char)
	for char in counts:
		if counts[char] >= 2:
			red += 1
		else:
			green += 1
	print(red + green // 2)


from collections import Counter
tc = int(input())
for _ in range(tc):
	string = input()
	occur = Counter(string)
	simple = sum([1 for v in occur.values() if v == 1])
	double_or_more = sum([1 for v in occur.values() if v > 1])
	print(double_or_more + simple // 2)


from collections import defaultdict
tc = int(input())
for _ in range(tc):
	s = input()
	f = defaultdict(int)
	for i in s:
		f[i] += 1
	(one, two, three) = (0, 0, 0)
	for i in f:
		if f[i] == 1:
			one += 1
		if f[i] == 2:
			two += 1
		if f[i] > 2:
			three += 1
	print(one // 2 + two + three)


for i in range(int(input())):
	s = input()
	n = len(s)
	r = set()
	g = set()
	i = 0
	d = {}
	for i in s:
		d[i] = d.get(i, 0) + 1
	r = 0
	g = 0
	for i in d.keys():
		if d[i] > 1:
			r += 1
			g += 1
		elif r > g:
			g += 1
		else:
			r += 1
	print(min(g, r))


t = int(input())
for i in range(0, t):
	d = dict()
	s = input()
	n = len(set(s))
	for j in range(0, len(s)):
		if d.get(s[j], False) == False:
			d[s[j]] = 1
		else:
			d[s[j]] += 1
	c1 = 0
	for i in d.keys():
		if d[i] == 1:
			c1 += 1
	c2 = n - c1
	print(c2 + c1 // 2)


from collections import Counter
from sys import stdin, stdout
import math
for _ in range(int(stdin.readline())):
	l = list(input())
	a = Counter(l)
	ans = 0
	for i in a:
		if a[i] >= 2:
			ans += 2
		else:
			ans += 1
	print(ans // 2)


from collections import defaultdict
t = int(input())
for _ in range(t):
	s = input()
	count = defaultdict(int)
	for c in s:
		count[c] += 1
	ans = 0
	singles = 0
	for key in count:
		if count[key] >= 2:
			ans += 1
		else:
			singles += 1
	ans += singles // 2
	print(ans)


t = int(input())
while t:
	s = input()
	p = set(s)
	d = 0
	c = 0
	for i in p:
		m = s.count(i)
		if m > 1:
			d += 1
		if m == 1:
			c += 1
	c = c // 2
	c += d
	print(c)
	t -= 1


t = int(input())
for _ in range(0, t):
	a = input()
	d = {}
	m = []
	for ele in a:
		if ele in d:
			d[ele] += 1
		else:
			d[ele] = 1
	for ele in d.values():
		if ele > 2:
			m.append(2)
		else:
			m.append(ele)
	c = sum(m)
	if c % 2 == 0:
		print(c // 2)
	else:
		print((c - 1) // 2)


for _ in range(int(input())):
	s = input()
	b = []
	for c in s:
		if b.count(c) < 2:
			b.append(c)
	print(len(b) // 2)


from collections import Counter
for i in range(int(input())):
	s = input()
	d = Counter(s)
	c1 = 0
	c2 = 0
	l = list(d.values())
	for i in range(len(l)):
		if l[i] > 1:
			c2 = c2 + 1
		else:
			c1 = c1 + 1
	print(int(c1 / 2) + c2)


for i in range(int(input())):
	s = input()
	green = 0
	red = 0
	for i in set(s):
		if s.count(i) >= 2:
			green = green + 1
			red = red + 1
		elif green > red:
			red = red + 1
		else:
			green = green + 1
	print(min(green, red))


from collections import Counter
for _ in range(int(input())):
	s = input()
	a = Counter(s)
	r = 0
	g = 0
	flag = False
	for (key, values) in a.items():
		if values >= 2:
			r += 1
			g += 1
		elif flag:
			g += 1
			flag = False
		else:
			r += 1
			flag = True
	print(min(r, g))


t = int(input())
for i in range(t):
	s = input()
	d = {}
	r = 0
	g = 0
	l = [j for j in s]
	l.sort()
	for j in l:
		if j not in d:
			if r == g:
				d[j] = 1
				r += 1
			elif r > g:
				d[j] = 0
				g += 1
			else:
				d[j] = 1
				r += 1
		elif d[j] != -1:
			if d[j] == 1:
				g += 1
			else:
				r += 1
			d[j] = -1
	print(min(r, g))


import os
import math
import sys
from collections import Counter
parse_input = lambda : sys.stdin.readline().rstrip('\r\n')

def func(s):
	n = len(s)
	if n < 2:
		return 0
	t_max = n // 2
	chars = Counter(s)
	(red, green) = ([], [])
	for (char, num) in chars.items():
		if num >= 2:
			red.append(char)
			green.append(char)
		elif len(red) > len(green):
			green.append(char)
		else:
			red.append(char)
	ans = min(len(red), len(green))
	return ans

def main():
	n_cases = int(parse_input())
	for i in range(n_cases):
		s = parse_input()
		print(func(s))
main()


for _ in range(int(input())):
	s = input()
	f = 26 * [0]
	for i in s:
		f[ord(i) - 97] += 1
	(x, y) = (0, 0)
	for i in range(26):
		if f[i] >= 2:
			x += 1
		elif f[i] == 1:
			y += 1
	if y % 2 != 0:
		y -= 1
	print(x + y // 2)


import math, sys, itertools
wtf = sys.stdin.read()
wtf = wtf.strip().split('\n')
n = int(wtf[0])
for s in wtf[1:]:
	sp1 = set(s)
	for si in sp1:
		s = s.replace(si, '', 1)
	sp2 = set(s)
	print((len(sp1) + len(sp2)) // 2)


def solution():
	for t in range(int(input())):
		s = input()
		n = len(s)
		ans = 0
		dic = {}
		for e in s:
			if e in dic:
				dic[e] += 1
			else:
				dic[e] = 1
		dk = sorted(dic.keys())
		(cnt1, cnt2) = (0, 0)
		for e in dk:
			if dic[e] == 1:
				cnt1 += 1
			else:
				cnt2 += 1
		ans = cnt2 + cnt1 // 2
		print(ans)
	return
solution()


import sys
input = lambda : sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
	S = sorted([(v, i) for (i, v) in enumerate([*input()])])
	c = dict()
	for (v, i) in S:
		if v in c:
			c[v] += 1
		else:
			c[v] = 1
	jaturi = 0
	res = 0
	for (k, v) in c.items():
		if v < 2:
			jaturi += 1
		else:
			res += 1
	print(res + jaturi // 2)


from collections import Counter
color_count = 2
for _ in range(int(input())):
	set_length = 0
	short_groups = 0
	for count in Counter(input()).values():
		if count >= color_count:
			set_length += 1
		else:
			short_groups += count
	set_length += short_groups // color_count
	print(set_length)


t = int(input())
for i in range(t):
	s = input()
	ss = set(s)
	k = 0
	z = 0
	for el in ss:
		if s.count(el) > 1:
			k += 1
			z += 1
		elif k >= z:
			z += 1
		elif z >= k:
			k += 1
	print(k)


t = int(input())
for i in range(t):
	b = 0
	c = 0
	string = str(input())
	set1 = list(set(string))
	a = len(set1)
	for i in range(a):
		if string.count(set1[i]) >= 2:
			b += 1
		else:
			c += 1
	print(int(b + c / 2))


test = int(input())
answer = []
for i in range(test):
	letters = {}
	total1 = 0
	count = 0
	s = list(input())
	for i in s:
		if i in letters:
			letters[i] += 1
		else:
			letters[i] = 1
	finletters = letters.values()
	for i in finletters:
		if i == 1:
			total1 += 1
		else:
			count += 1
	count += total1 // 2
	answer.append(count)
for i in answer:
	print(i)


def countPaint(s):
	lst = [0] * 26
	for i in s:
		lst[ord(i) - 97] += 1
	d = lst.count(0)
	a = lst.count(1)
	b = lst.count(2)
	c = lst.count(3)
	return a // 2 + b + c + (len(lst) - d - a - b - c)
t = int(input())
for i in range(t):
	s = input()
	print(countPaint(s))


cases = int(input())
for case in range(cases):
	st = input()
	dict = {}
	for letter in st:
		if letter not in dict:
			dict[letter] = 1
		elif dict[letter] < 2:
			dict[letter] += 1
	total = 0
	for key in dict.keys():
		total += dict[key]
	print(total // 2)


from collections import Counter
t = int(input())
for _ in range(t):
	ali = list(input())
	d = Counter()
	for i in range(len(ali)):
		d[ali[i]] += 1
	cnt = 0
	for i in d:
		if d[i] >= 2:
			cnt += 2
		else:
			cnt += 1
	print(cnt // 2)


import time
from queue import Queue
from itertools import accumulate, count
from io import BytesIO, IOBase
from itertools import combinations
import threading
from collections import deque
from functools import reduce, cmp_to_key
import sys
from math import sqrt
import heapq
import random
import math
from collections import defaultdict
from collections import Counter
import io
import os
import bisect
from fractions import Fraction

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def swap(arr, a, b):
	(arr[a], arr[b]) = (arr[b], arr[a])
for _ in range(iinput()):
	s = input()
	d = defaultdict(int)
	for i in s:
		d[i] += 1
	s = 0
	for i in d:
		s += min(d[i], 2)
	print(s // 2)


from sys import stdin, stdout
from collections import Counter, defaultdict
nmbr = lambda : int(input())
lst = lambda : list(map(int, input().split()))
for _ in range(nmbr()):
	s = input()
	d = Counter(s)
	t1 = defaultdict(int)
	t2 = defaultdict(int)
	odd = 0
	for (k, v) in d.items():
		if v >= 2:
			t1[k] += 1
			t2[k] += 1
		if v == 1:
			odd += 1
	t2odd = t1odd = odd // 2
	print(sum(t1.values()) + t1odd)


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	s = st()
	d = Counter(s)
	ans = 0
	odd = 0
	for i in d:
		ans += d[i] > 1
		odd += d[i] == 1
	ans += odd // 2
	pr(ans)
for _ in range(inp()):
	solve()


for i in range(int(input())):
	s = input()
	ct1 = ct2 = 0
	for i in set(s):
		if s.count(i) >= 2:
			ct1 += 1
		else:
			ct2 += 1
	print(ct1 + ct2 // 2)


def wonderfulColoring(s):
	(dic, total) = ({}, 0)
	for i in s:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
	for i in dic:
		if dic[i] > 2:
			dic[i] = 2
		total += dic[i]
	return total // 2
t = int(input())
for i in range(t):
	s = input()
	print(wonderfulColoring(s))


from sys import stdin, stdout
print = stdout.write
input = stdin.readline
from collections import defaultdict

def solve_test():
	counter = defaultdict(int)
	a = list(input()[:-1])
	k = 2
	colours = [0 for _ in range(k)]
	for x in a:
		counter[x] += 1
	i = 0
	for number in counter:
		for _ in range(min(counter[number], k)):
			colours[i] += 1
			i += 1
			i %= k
	painted = min(colours)
	return painted

def main(args=None):
	tests = int(input())
	for _ in range(tests):
		print(f'{solve_test()}\n')
main()


for _ in range(int(input())):
	c = {}
	for x in input():
		c[x] = c.get(x, 0) + 1
	r = 0
	o = 0
	for v in c.values():
		if v > 1:
			r += 1
		else:
			o += 1
	print(r + o // 2)


from collections import Counter
for _ in range(int(input())):
	s = str(input())
	count = Counter(s)
	(r, g) = (0, 0)
	for i in count:
		x = count[i]
		if x >= 2:
			r += 1
			g += 1
		if x < 2:
			if r < g:
				r += 1
			elif r > g:
				g += 1
			else:
				r += 1
	print(min(r, g))


for _ in range(int(input())):
	s = input()
	dp = []
	r = 0
	g = 0
	for c in s:
		if c not in dp or dp.count(c) == 1:
			dp.append(c)
			if r <= g:
				r += 1
			else:
				g += 1
	print(min(r, g))


for _ in range(int(input())):
	str1 = input()
	dict1 = {}
	res = 0
	for i in str1:
		try:
			dict1[i] += 1
		except:
			dict1[i] = 1
	for (k, v) in dict1.items():
		if v == 1:
			res += 1
		elif v >= 2:
			res += 2
	print(res // 2)


T = int(input())
from collections import defaultdict
for _ in range(T):
	S = input()
	K = 2
	ans = [0] * len(S)
	dic = defaultdict(lambda : [])
	for (i, a) in enumerate(S):
		dic[a].append(i)
	stack = []
	for v in dic.values():
		if len(v) < K:
			for i in v:
				stack.append(i)
		else:
			for (j, i) in enumerate(v[:K]):
				ans[i] = j + 1
	while len(stack) % K:
		stack.pop()
	for (j, i) in enumerate(stack):
		ans[i] = j % K + 1
	print(ans.count(1))


for i in range(int(input())):
	s = input()
	more_than_2 = 0
	less_than_2 = 0
	for j in set(s):
		if s.count(j) >= 2:
			more_than_2 += 1
		else:
			less_than_2 += 1
	print(more_than_2 + less_than_2 // 2)


tests = int(input())
for _ in range(tests):
	dc = dict()
	for c in input():
		dc[c] = dc.get(c, 0) + 1
	cnt = [0, 0, 0]
	for v in dc.values():
		if v == 1:
			cnt[1] += 1
		else:
			cnt[2] += 1
	res = cnt[1] // 2 + cnt[2]
	print(res)


import os, sys
isCoding = os.environ.get('CODE_ENV', '') != ''
if isCoding:
	sys.stdin = open('../input.txt', 'r')
for _ in range(int(input())):
	s = input()
	a = [0] * 26
	for x in s:
		a[ord(x) - 97] += 1
	ans = [0, 0]
	for x in a:
		if x > 1:
			ans[0] += 1
			ans[1] += 1
		elif x == 1:
			if ans[0] > ans[1]:
				ans[1] += 1
			else:
				ans[0] += 1
	print(min(ans[0], ans[1]))


from collections import Counter
for _ in range(int(input())):
	s = input().strip()
	f = 0
	t = 0
	c = Counter(s)
	for i in c:
		if c[i] > 1:
			t += 1
		else:
			f += 1
	print(f // 2 + t)


from sys import stdin
input = lambda : stdin.readline().strip()
lin = lambda : list(map(int, input().split()))
iin = lambda : int(input())
main = lambda : map(int, input().split())
from math import ceil, sqrt, factorial, log
from collections import deque
from bisect import bisect_left
mod = 998244353
mod = 1000000007

def solve(we):
	s = input()
	(a, b, c) = (0, 0, 0)
	d = {}
	for i in s:
		if i not in d:
			d[i] = 0
		d[i] += 1
	for i in d:
		if d[i] == 1:
			a += 1
		else:
			b += 1
	x = a + 2 * b
	print(x // 2)
qwe = 1
qwe = iin()
for _ in range(qwe):
	solve(_ + 1)


t = int(input())
natija = []
for i in range(t):
	s = input()
	k = 0
	harflar = []
	juftmas_harflar = 0
	for i in range(26):
		harflar.append(0)
	for c in s:
		harflar[ord(c) - 97] += 1
	for i in range(26):
		if harflar[i] > 1:
			k += 1
		elif harflar[i] == 1:
			juftmas_harflar += 1
	k += juftmas_harflar // 2
	natija.append(k)
for i in range(t):
	print(natija[i])


from collections import defaultdict
for _ in range(int(input())):
	s = input()
	d = defaultdict(lambda : 0)
	for i in s:
		d[i] += 1
	ans = len(d) // 2
	c = 0
	for i in d:
		if d[i] >= 2:
			c += 1
	if len(d) % 2 != 0:
		c += 1
	print(ans + c // 2)


from collections import Counter
for i in range(int(input())):
	string = input()
	counter = Counter(string)
	count = 0
	other = 0
	for (a, b) in counter.items():
		if b >= 2:
			count += 1
		else:
			other += 1
	if len(counter) > 1:
		print(count + other // 2)
	elif len(string) > 1:
		print(1)
	else:
		print(0)


t = int(input())
for k in range(t):
	(count1, count2) = (0, 0)
	has = {}
	s = input()
	if len(s) == 1:
		print(0)
	else:
		for i in s:
			if i not in has:
				has[i] = 1
			else:
				has[i] += 1
		for i in has:
			if has[i] >= 2:
				count1 += 1
			else:
				count2 += 1
		print(count1 + count2 // 2)


def laske(luku: str):
	pass

def main2():
	mjono = 'xxxxxx'
	maarat = {}
	summa = 0
	for merkki in mjono:
		if not merkki in maarat:
			maarat[merkki] = 0
		if maarat[merkki] < 2:
			maarat[merkki] += 1
			summa += 1
	print(summa // 2)

def main():
	t = int(input())
	mjonot = []
	for i in range(1, t + 1):
		mjono = input()
		mjonot.append(mjono)
	for mjono in mjonot:
		maarat = {}
		summa = 0
		for merkki in mjono:
			if not merkki in maarat:
				maarat[merkki] = 0
			if maarat[merkki] < 2:
				maarat[merkki] += 1
				summa += 1
		print(summa // 2)
main()


for g in [*open(0)][1:]:
	g = g.strip()
	s = set(g)
	t = 0
	for c in s:
		t = t + 1 + 1 * (g.count(c) > 1)
	print(t // 2)


test = int(input())
for i in range(test):
	s = input()
	m = dict()
	for ch in s:
		m[ch] = m.get(ch, 0) + 1
	count = 0
	for value in m.values():
		if value > 2:
			count += 2
		else:
			count += value
	print(count // 2)


n = int(input())
for i in range(0, n):
	s = input()
	frq = {}
	for j in s:
		if j in frq:
			frq[j] += 1
		else:
			frq[j] = 1
	s = 0
	temp = 0
	for i in frq.keys():
		if frq[i] >= 2:
			s += 1
		else:
			temp += 1
	s += temp // 2
	print(s)


import math as m
import sys
for _ in range(int(input())):
	s = input()
	a = []
	for i in range(ord('a'), ord('z') + 1):
		a.append(s.count(chr(i)))
	ans = 0
	for x in a:
		ans += min(2, x)
	print(ans // 2)


from collections import defaultdict
tests = int(input())
for i in range(tests):
	st = input()
	d = defaultdict(int)
	for s in st:
		if d[s] < 2:
			d[s] += 1
	print(sum(d.values()) // 2)


t = int(input())
while t:
	t -= 1
	s = input()
	d = {}
	r = set()
	g = set()
	for i in range(len(s)):
		if s[i] not in d:
			d[s[i]] = 1
		else:
			d[s[i]] += 1
	c1 = 0
	c2 = 0
	for key in d:
		if d[key] == 1:
			c1 += 1
		else:
			c2 += 1
	print(c2 + c1 // 2)


for _ in range(int(input())):
	n = input()
	d = dict()
	for i in n:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	a = []
	ones = 0
	ans = 0
	l = []
	for key in d.values():
		l.append(key)
	for j in l:
		if j == 1:
			ones += 1
		else:
			ans += 1
	print(ans + ones // 2)


import sys
N = int(200000.0 + 5)
LEN = 26
sys.setrecursionlimit(N)

def charming():
	s = input()
	cnt = [0] * LEN
	for ch in s:
		cnt[ord(ch) - ord('a')] += 1
	res = 0
	more = 0
	for i in cnt:
		if i > 1:
			res += 1
		elif i == 1:
			more += 1
	print(res + more // 2)
for t in range(int(input())):
	charming()


t = int(input())
for i in range(t):
	x = list(input())
	arr = [0] * (ord('z') + 2)
	count = 0
	c1 = 0
	c2 = 0
	for c in x:
		arr[ord(c)] = arr[ord(c)] + 1
	for j in range(ord('a'), ord('z') + 1, 1):
		if arr[j] >= 2:
			c2 = c2 + 1
		elif arr[j] == 1:
			c1 = c1 + 1
	count = c2 + int(c1 / 2)
	print(count)


def color(s):
	n = len(s)
	if n == 1 or n == 2:
		return n - 1
	l = []
	for i in s:
		l.append(i)
	l = list(set(l))
	c = 0
	for i in l:
		if s.count(i) == 1:
			c += 1
	p = c // 2
	r = len(l) - c
	return p + r
for _ in range(int(input())):
	s = input()
	print(color(s))


t = int(input())
s = []
for i in range(t):
	s.append(input(''))
for i in range(t):
	r = 0
	g = 0
	freq = ['' for _ in range(200)]
	for j in range(len(s[i])):
		if 'g' in freq[ord(s[i][j])]:
			if 'r' in freq[ord(s[i][j])]:
				continue
			else:
				r += 1
				freq[ord(s[i][j])] += 'r'
		elif 'r' in freq[ord(s[i][j])] and 'g' not in freq[ord(s[i][j])]:
			g += 1
			freq[ord(s[i][j])] += 'g'
		elif r < g:
			r += 1
			freq[ord(s[i][j])] += 'r'
		else:
			g += 1
			freq[ord(s[i][j])] += 'g'
	print((r + g) // 2)


for _ in range(int(input().strip())):
	s = input().strip()
	counts = dict()
	for i in range(len(s)):
		counts[s[i]] = counts.get(s[i], 0) + 1
	single = 0
	double = 0
	for (k, v) in counts.items():
		if v == 1:
			single += 1
		elif v >= 2:
			double += 1
	ans = double + single // 2
	print(ans)


t = int(input())

def coloured(s):
	letters = [0] * 123
	for symbol in s:
		letters[ord(symbol)] += 1
	unique = 0
	answer = 0
	for counter in letters:
		if counter == 1:
			unique += 1
		if counter > 1:
			answer += 1
	answer += unique // 2
	return answer
for _ in range(t):
	s = input()
	print(coloured(s))


for _ in range(int(input())):
	s = input()
	l = set(s)
	(even, first) = (0, 0)
	for i in l:
		if s.count(i) > 1:
			even += 1
		else:
			first += 1
	print(even + first // 2)


for _ in range(int(input())):
	s = input()
	h = {}
	for i in s:
		h[i] = h.get(i, 0) + 1
	n = len(s)
	if n == 1:
		print(0)
		continue
	cnt = 0
	if len(h) == n:
		print(n // 2)
	else:
		o = 0
		for i in h:
			if h[i] % 2 == 0:
				cnt += 1
			else:
				if h[i] > 2:
					o += 1
				o += 1
		print(cnt + o // 2)


import sys, math
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
mod = 10 ** 9 + 7
input = lambda : sys.stdin.readline().rstrip()

def li():
	return list(map(int, input().split()))
t = int(input())
for _ in range(t):
	C = list(input())
	C.sort()
	a = set()
	an = 0
	b = set()
	bn = 0
	for c in C:
		if c in a and c in b:
			continue
		elif c in a:
			b.add(c)
			bn += 1
		elif c in b:
			a.add(c)
			an += 1
		elif an <= bn:
			a.add(c)
			an += 1
		else:
			b.add(c)
			bn += 1
	print(min(len(a), len(b)))


import collections
import math

def solve():
	r = 0
	g = 0
	s = input()
	d = collections.Counter(s)
	for i in d:
		if d[i] >= 2:
			r += 1
			g += 1
		elif r == g:
			g += 1
		elif g > r:
			r += 1
	return r
t = int(input())
for i in range(t):
	print(solve())


t = int(input())
for _ in range(t):
	s = input()
	a = set()
	b = set()
	for c in s:
		if c in b:
			a.add(c)
			if len(a) - len(b) == 2:
				for x in a:
					if x not in b:
						b.add(x)
						a.remove(x)
						break
		else:
			b.add(c)
			if len(b) - len(a) == 2:
				for x in b:
					if x not in a:
						a.add(x)
						b.remove(x)
						break
	print(min(len(a), len(b)))


for i in range(int(input())):
	sl = {}
	a = list(input())
	b = len(a)
	for el in a:
		if el not in sl.keys():
			sl[el] = 1
		else:
			sl[el] += 1
	for el in sl.keys():
		if sl[el] > 2:
			b += 2 - sl[el]
	print(b // 2)


t = int(input())
for i in range(t):
	s = input()
	d = {}
	for j in s:
		if j in d:
			d[j] += 1
		else:
			d[j] = 1
	l = list(d.values())
	c = 0
	for k in l:
		if k >= 2:
			c += 1
	print(c + (len(l) - c) // 2)


t = int(input())
for _ in range(t):
	s = input()
	a = list(set(s))
	b = list(s)
	total = 0
	if len(s) == len(a):
		print(int(len(s) // 2))
	else:
		for x in range(len(a)):
			if b.count(a[x]) >= 2:
				total += 2
			else:
				total += 1
		print(int(total // 2))


from collections import Counter
for _ in range(int(input())):
	s = input()
	d = Counter(s)
	ans = 0
	c = 0
	for (k, v) in d.items():
		if v == 1:
			if c == 0:
				c += 1
			else:
				c = 0
				ans += 1
		else:
			ans += 1
	if c == 2:
		ans += 1
	print(ans)


from sys import *
input = stdin.readline
t = int(input())
for _ in range(t):
	s = input().strip()
	l = [-1] * 26
	c = 0
	for i in range(len(s)):
		x = ord(s[i]) - 97
		if l[x] == -1:
			c += 1
			l[x] = i
		elif l[x] != -2:
			c += 1
			l[x] = -2
	print(c // 2)


for _ in range(int(input())):
	s = input()
	n = len(s)
	ans = 0
	mapper = {}
	for i in s:
		if i in mapper:
			mapper[i] += 1
		else:
			mapper[i] = 1
	d = 0
	si = 0
	for i in mapper:
		if mapper[i] > 1:
			d += 1
		else:
			si += 1
	print(d + si // 2)


for _ in range(int(input())):
	s = input()
	helper = {}
	if len(s) == 1:
		print(0)
		continue
	for i in s:
		helper[i] = helper.get(i, 0) + 1
	(g, r) = (0, 0)
	for i in helper:
		if helper[i] >= 2:
			g += 1
			r += 1
		elif g < r:
			g += 1
		else:
			r += 1
	if r > g:
		print(r - 1)
	else:
		print(r)


from collections import *
t = int(input())
for i in range(t):
	n = input()
	s = 0
	r = 0
	if len(n) == 1:
		print('0')
	elif len(set(n)) == 1:
		print('1')
	else:
		for (i, x) in Counter(n).items():
			if x == 1:
				s += 1
			else:
				r += 2
		m = s // 2
		a = r // 2
		print(m + a)


t = int(input())
for _ in range(t):
	a = input()
	l = len(a)
	red = 0
	green = 0
	hist_a = {}
	for i in a:
		try:
			hist_a[i] += 1
		except:
			hist_a[i] = 1
	for i in hist_a:
		if hist_a[i] >= 2:
			red += 1
			green += 1
		elif red == green:
			red += 1
		else:
			green += 1
	if red == green:
		print(red)
	else:
		print(green)


from collections import Counter
q = int(input())
for _ in range(q):
	s = input()
	c = Counter(s)
	ans = 0
	d = 0
	for i in c:
		if c[i] >= 2:
			ans += 1
		elif c[i] == 1:
			d += 1
	ans += d // 2
	print(ans)


for i in range(int(input())):
	x = list(input())
	y = list(set(x))
	sol = 0
	res = []
	for i in y:
		if x.count(i) >= 3:
			sol += 1
		elif x.count(i) == 2:
			sol += 1
		else:
			sol += 0.5
	print(int(sol))


N = int(input())
ans = [0] * N
for j in range(N):
	s = input()
	arr = [0] * 26
	for i in s:
		symb = ord(i) - 97
		if arr[symb] < 2:
			arr[symb] += 1
	d = 0
	si = 0
	for i in range(26):
		if arr[i] == 2:
			d += 1
		if arr[i] == 1:
			si += 1
	ans[j] = d + si // 2
for i in range(N):
	print(ans[i])


from collections import Counter

def result(a):
	qw = Counter(a)
	count1 = 0
	count2 = 0
	for (key, value) in qw.items():
		if value >= 2:
			count2 += 1
		else:
			count1 += 1
	print(count1 // 2 + count2)
for i in range(int(input())):
	result(input())


for _ in range(int(input())):
	st = input()
	alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
	ans = 0
	for i in alpha:
		ans += min(2, st.count(i))
	print(ans // 2)


from typing import Collection

def u():
	return map(int, input().split())
for _ in range(int(input())):
	d = dict()
	s = input()
	colrable = 0
	for el in s:
		if el in d:
			if d[el] >= 2:
				pass
			else:
				d[el] += 1
				colrable += 1
		else:
			colrable += 1
			d[el] = 1
	print(colrable // 2)


for _ in range(int(input())):
	(a, b, d) = (0, 0, {})
	for i in input():
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	for i in d:
		if d[i] >= 2:
			a += 1
		else:
			b += 1
	print(a + b // 2)


for i in range(int(input())):
	s = input()
	s1 = set(s)
	c = 0
	s2 = ''
	if len(s) == 1:
		print(0)
	else:
		for i in s1:
			if s.count(i) > 1:
				c += 1
			else:
				s2 += i
		print(c + len(s2) // 2)


def sol(A, k):
	dic = {}
	for a in A:
		if a in dic:
			dic[a] += 1
		else:
			dic[a] = 1
	ans = 0
	for key in dic.keys():
		ans += min(k, dic[key])
	return ans // k
x = int(input())
for _ in range(x):
	k = 2
	A = [a for a in input()]
	print(sol(A, k))


T = int(input())
for t in range(T):
	a = input()
	k = 2
	a_dict = {}
	a_color_dict = {}
	distinct_set = set()
	distinct_over = set()
	for a_i in a:
		if a_i in a_dict:
			a_dict[a_i] += 1
			if a_dict[a_i] > k and a_i not in distinct_over:
				distinct_over.add(a_i)
				a_color_dict[a_i] = [num for num in range(1, k + 1)]
		else:
			a_dict[a_i] = 1
			a_color_dict[a_i] = []
			distinct_set.add(a_i)
	next_num = 0
	distinct_under_list = list(distinct_set - distinct_over)
	for a_i in distinct_under_list:
		num = a_dict[a_i]
		if distinct_under_list[-1] == a_i and next_num == 0 and (num < k):
			break
		for i in range(num):
			a_color_dict[a_i].append(next_num + 1)
			next_num += 1
			if distinct_under_list[-1] == a_i and next_num == k:
				break
			next_num %= k
	color_list = []
	color_sum = 0
	for a_i in a:
		if len(a_color_dict[a_i]) > 0:
			color = a_color_dict[a_i].pop()
			if color == 1:
				color_sum += 1
			color_list.append(color)
		else:
			color_list.append(0)
	print(color_sum)


from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush
import os, sys
input = lambda : sys.stdin.buffer.readline().rstrip(b'\r\n')

def dbp(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)
a_str = lambda : input().decode('ascii')
get_int_list = lambda : [int(x) for x in input().split()]
join_str = lambda l, ch=' ': ch.join((str(x) for x in l))

def IR_SO_DUMN(s, k=2):
	d = defaultdict(list)
	for (idx, ch) in enumerate(s):
		d[ch].append(idx)
	ans = [None] * len(s)
	ccol = 0
	for (ch, il) in d.items():
		used = set()
		for idx in il:
			used.add(ccol)
			ans[idx] = ccol + 1
			ccol = (ccol + 1) % k
			if ccol in used:
				break
	return min((ans.count(c) for c in range(1, k + 1)))

def wa(s):
	d = defaultdict(set)
	ans = [None] * len(s)
	colheap = [(0, i) for i in range(2)]
	heapify(colheap)
	for (idx, ch) in enumerate(s):
		colstack = []
		(count, col) = heappop(colheap)
		while col in d[ch] and colheap:
			colstack.append((count, col))
			(count, col) = heappop(colheap)
		if col not in d[ch]:
			ans[idx] = col
			d[ch].add(col)
			heappush(colheap, (count + 1, col))
		else:
			colstack.append((count, col))
		for cs in colstack:
			heappush(colheap, cs)
	dbp(ans)
	return min((ans.count(k) for k in range(2)))

def do_thing():
	s = input()
	return IR_SO_DUMN(s)

def multicase():
	maxcc = int(input().strip())
	for cc in range(maxcc):
		print(do_thing())
multicase()


for i in range(int(input())):
	s = input()
	n = 0
	for c in 'abcdefghijklmnopqrstuvwxyz':
		p = s.count(c)
		if p == 1:
			n += 1
		elif p >= 2:
			n += 2
		p = 0
	print(n // 2)


t = int(input())
l = []
for i in range(t):
	l.append(input())
for i in range(t):
	dict = {}
	x = []
	for j in range(len(l[i])):
		x.append(l[i][j])
	x = list(set(x))
	for m in range(len(x)):
		dict[x[m]] = l[i].count(x[m])
	ans = 0
	temp = 0
	for key in dict.keys():
		if dict[key] >= 2:
			ans = ans + 1
		elif dict[key] == 1:
			temp = temp + 1
	ans = ans + temp / 2
	print(int(ans))


from collections import Counter
t = int(input())
for _ in range(t):
	s = input()
	new = Counter(s)
	cnt1 = 0
	cnt2 = 0
	for i in new.values():
		if i == 1:
			cnt1 += 1
		elif i > 0:
			cnt2 += 1
	print(cnt2 + cnt1 // 2)


import sys

def read_int():
	return int(sys.stdin.readline())

def read_ints():
	return list(map(int, sys.stdin.readline().split()))

def write(x):
	sys.stdout.write(x + '\n')
for _ in '.' * read_int():
	s = input()
	one_time = 0
	done = []
	count = 0
	for ch in s:
		if ch in done:
			continue
		if s.count(ch) == 1:
			one_time += 1
			done.append(ch)
		else:
			count += 1
			done.append(ch)
	count += one_time // 2
	write(str(count))


from collections import defaultdict
t = int(input())
for _ in range(t):
	mp = defaultdict(int)
	strx = input()
	for i in strx:
		mp[i] += 1
	c2 = 0
	c1 = 0
	for (k, v) in mp.items():
		if v >= 2:
			c2 += 1
		else:
			c1 += 1
	print(c1 // 2 + c2)


for i in range(int(input())):
	s = input()
	a = 0
	x = []
	for i in s:
		if x.count(i) < 2:
			a += 1
			x.append(i)
	print(a // 2)


from string import ascii_lowercase
for _ in range(int(input())):
	s = input()
	cnt = dict.fromkeys(ascii_lowercase, 0)
	a = 0
	for i in s:
		cnt[i] += 1
	for i in s:
		if cnt[i] >= 2:
			a += 1
			cnt[i] = 0
	k = [i for i in cnt if cnt[i] != 0]
	print(a + len(k) // 2)


t = int(input())
for i in range(t):
	s = input()
	a = list(set(s))
	b = [0] * len(a)
	for x in range(len(a)):
		for y in range(len(s)):
			if s[y] == a[x]:
				b[x] += 1
	ans = 0
	k = 0
	for x in range(len(b)):
		if b[x] >= 2:
			ans += 1
		else:
			k += 1
	print(ans + k // 2)


n = int(input())
for i in range(n):
	z = input()
	dict = {}
	for j in z:
		try:
			dict[j] += 1
		except KeyError:
			dict[j] = 1
	red = 0
	green = 0
	painted = 0
	unpainted = 0
	for value in dict.values():
		if value == 2:
			red += 1
			green += 1
		elif value == 3:
			red += 1
			green += 1
			painted += 1
		elif value == 1:
			red += 1
		else:
			red += 1
			green += 1
			painted += value - 2
	while red > green:
		red -= 1
		green += 1
	print(red)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		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')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
for t in range(int(input())):
	s = input()
	if len(set(s)) == len(s):
		if len(s) % 2 == 0:
			print(len(s) // 2)
		else:
			print((len(s) - 1) // 2)
	else:
		(red, green) = (0, 0)
		for unique in set(s):
			c = s.count(unique)
			if c == 1:
				if red < green:
					red += 1
				else:
					green += 1
			elif c == 2:
				red += 1
				green += 1
			else:
				red += 1
				green += 1
		if red == green:
			print(red)
		else:
			print(min(red, green))


for i in range(int(input())):
	string = input()
	count = 0
	wait = 0
	list1 = []
	list2 = []
	for i in string:
		if i in list2:
			continue
		list2.append(i)
		if string.count(i) > 1:
			count += 1
			string = string.replace(i, '')
		else:
			wait += 1
		if wait % 2 == 0 and wait != 0 and (wait not in list1):
			list1.append(wait)
			count += 1
		if len(string) == wait or len(string) == 0:
			break
	print(count)


for _ in range(int(input())):
	s = input()
	d = {}
	for i in s:
		d[i] = d.get(i, 0) + 1
	t = 0
	o = 0
	for i in d:
		if d[i] >= 2:
			t += 1
		else:
			o += 1
	print(t + o // 2)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
inp = lambda : list(map(int, sys.stdin.readline().rstrip('\r\n').split()))
mod = 10 ** 9 + 7
Mod = 998244353
INF = float('inf')
import math
from bisect import *
from heapq import *
from collections import defaultdict as dd
from collections import OrderedDict as odict
from collections import Counter as cc
from collections import deque
from itertools import groupby
sys.setrecursionlimit(20 * 20 * 20 * 20 + 10)

def solve():
	string = takesr()
	dict_1 = cc(string)
	count = red = 0
	for (key, value) in dict_1.items():
		if value >= 2:
			count += 1
		if value == 1:
			red += 1
	print(count + red // 2)

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = takein()
	for tt in range(1, t + 1):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

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

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

def takeiar():
	return list(map(int, sys.stdin.readline().rstrip('\r\n').split()))

def takesar():
	return list(map(str, sys.stdin.readline().rstrip('\r\n').split()))

def takeivr():
	return map(int, sys.stdin.readline().rstrip('\r\n').split())

def takesvr():
	return map(str, sys.stdin.readline().rstrip('\r\n').split())

def ispalindrome(s):
	return s == s[::-1]

def invert(bit_s):
	temp = int(bit_s, 2)
	inverse_s = temp ^ 2 ** (len(bit_s) + 1) - 1
	rslt = bin(inverse_s)[3:]
	return str(rslt)

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def factorial(n, m=1000000007):
	q = 1
	for i in range(n):
		q = q * (i + 1) % m
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b

def power_two(x):
	return x and (not x & x - 1)

def ceil(a, b):
	return -(-a // b)

def seive(n):
	a = [1]
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p ** 2, n + 1, p):
				prime[i] = False
		p = p + 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)
	return a

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def binary_search(li, val):
	ans = -1
	lb = 0
	ub = len(li) - 1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


from sys import stdin

def solve():
	seq = stdin.readline().strip()
	l = []
	d = {1: 1}
	for i in seq:
		if i not in l:
			l.append(i)
			d[i] = 1
		elif i in l and d[i] == 1:
			l.append(i)
			d[i] = 2
	n = len(l)
	print(n // 2)
t = int(stdin.readline().strip())
for _ in range(t):
	solve()


for _ in range(int(input())):
	s = input()
	cnt = [0] * 26
	for c in s:
		cnt[ord(c) - 97] += 1
	ans = 0
	for i in range(26):
		ans += min(cnt[i], 2)
	print(ans // 2)


for _ in range(int(input())):
	s = input()
	t = ''
	(rr, gg, c) = (0, 0, 0)
	for i in s:
		if s.count(i) > 1:
			if i not in t:
				rr += 1
				t = t + i
			else:
				pass
		else:
			c += 1
	c = c // 2
	print(rr + c)


import string

def main():
	from sys import stdin, stdout
	t = int(input())
	for _ in range(t):
		d = dict(((key, 0) for key in string.ascii_lowercase))
		n = str(input())
		for i in range(len(n)):
			d[n[i]] += 1
		newn = len(n)
		for i in d.keys():
			if d[i] > 2:
				newn -= d[i] - 2
		print(newn // 2)
main()


t = int(input())
while t:
	string = input()
	ls = list(string)
	st = set(string)
	d = dict()
	ones = 0
	ans = 0
	for letter in st:
		d[letter] = ls.count(letter)
	for value in d.values():
		if value > 1:
			ans += 1
		elif value == 1:
			ones += 1
	ans += ones // 2
	print(ans)
	t -= 1


test_cases = int(input(''))
for test in range(test_cases):
	my_str = str(input(''))
	arr_res = list()
	while len(my_str) > 0:
		letter = my_str[0]
		arr_res.append(my_str.count(letter))
		my_str = my_str.replace(letter, '')
	counter = 0
	ones_counter = 0
	for i in range(len(arr_res)):
		if arr_res[i] >= 2:
			counter += 1
		else:
			ones_counter += 1
	counter = counter + int(ones_counter / 2)
	print(counter)


from collections import Counter
for i in range(int(input())):
	s = input()
	l = list(Counter(s).values())
	c = 0
	d = 0
	for i in range(len(l)):
		if l[i] == 1:
			d += 1
		elif l[i] == 2:
			c += 1
		elif l[i] > 2:
			c += 1
	c += d // 2
	print(c)


n = int(input())
for i in range(n):
	t = []
	x = input()
	[t.append(i) for i in x if i not in t]
	c = 0
	d = 0
	for j in t:
		if x.count(j) >= 2:
			c += 1
		else:
			d += 1
	ans = c + d // 2
	print(ans)


import itertools
for _ in itertools.repeat(None, int(input())):
	st = list(input())
	st.sort()
	single = []
	double = []
	for (key, group) in itertools.groupby(st):
		ok = list(group)
		if len(ok) > 1:
			double.append(ok)
		else:
			single.append(ok)
	cnt = len(double) + len(single) // 2
	print(cnt)


import sys
import heapq
from collections import defaultdict
import re
import math
input = sys.stdin.readline
t = int(input())
for i1 in range(1, t + 1):
	s = input().strip()
	d = {}
	for i in s:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	cnt = 0
	for i in d:
		if d[i] > 2:
			cnt += 2
		else:
			cnt += d[i]
	print(cnt // 2)


t = int(input())
for _ in range(t):
	s = list(input())
	l = [0] * 26
	for i in range(len(s)):
		k = ord(s[i]) - ord('a')
		l[k] += 1
	ans = 0
	for i in range(len(l)):
		ans = ans + min(l[i], 2)
	ans = ans // 2
	print(ans)


from collections import Counter

def solve(s):
	if len(s) == 1:
		return 0
	dict = Counter(s)
	red = 0
	green = 0
	ans = True
	for i in range(0, len(s)):
		if dict[s[i]] == 2:
			red = red + 1
			green = green + 1
			dict.pop(s[i])
			ans = True
		if dict[s[i]] == 3:
			red = red + 1
			green = green + 1
			dict.pop(s[i])
			ans = True
		if dict[s[i]] > 3:
			red = red + 1
			green = green + 1
			dict.pop(s[i])
	left = 0
	for i in dict.values():
		if i == 1:
			left += 1
	if left % 2 == 0:
		red += left // 2
		green = red
		left = 0
	elif left % 2 == 1:
		red += left // 2
		green = red
		left = 0
	return red
t = int(input())
for i in range(t):
	s = input()
	print(solve(s))


for _ in range(int(input())):
	n = list(input())
	(c1, c2) = (0, 0)
	for i in set(n):
		if n.count(i) == 1:
			c1 += 1
		else:
			c2 += 1
	print(c1 // 2 + c2)


t = int(input())
out = []
while t:
	l1 = []
	l2 = []
	s = input()
	for i in s:
		if s.count(i) > 1 and i not in l1:
			l1.append(i)
		elif s.count(i) == 1:
			l2.append(i)
	out.append(len(l1) + len(l2) // 2)
	t -= 1
for i in out:
	print(i)


for _ in range(int(input())):
	d = {}
	s = list(input())
	for i in s:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	one = []
	cnt = 0
	for (k, v) in d.items():
		if v > 1:
			cnt += 1
		else:
			one += [k]
	cnt += len(one) // 2
	print(cnt)


t = int(input())
for i in range(t):
	s = str(input())
	st = set(s)
	red = 0
	cnt = 0
	for i in st:
		if s.count(i) > 1:
			red += 1
		else:
			cnt += 1
	print(red + cnt // 2)


for i in range(int(input())):
	s = input().strip()
	arr = [0] * 26
	j = 0
	for i in s:
		if arr[ord(i) - 97] < 2:
			arr[ord(i) - 97] += 1
			j += 1
	if j % 2 == 0:
		print(j // 2)
	else:
		print((j - 1) // 2)


from sys import stdin
from collections import defaultdict
for _ in range(int(stdin.readline())):
	s = input()
	if len(s) == 1:
		print('0')
		continue
	hash_map = defaultdict(int)
	for char in s:
		hash_map[char] = hash_map[char] + 1
	ans = 0
	curr_count = 0
	for key in sorted(hash_map, key=lambda x: hash_map[x]):
		curr_count += hash_map[key]
		if curr_count >= 2:
			ans += 1
			curr_count = 0
	print(ans)


t = int(input())
for k in range(t):
	s = input()
	st1 = set()
	st2 = set()
	for c in s:
		if c not in st1:
			st1.add(c)
		else:
			st2.add(c)
	print(min(len(st1), len(s) // 2, (len(st2) + len(st1)) // 2))


t = int(input())
for i in range(t):
	s = input()
	d = {}
	for j in s:
		cnt = 0
		for k in s:
			if k == j:
				cnt += 1
		d[j] = cnt
	count = list(d.values())
	res = 0
	c1 = 0
	for x in range(len(count)):
		if count[x] == 2:
			res += 1
		elif count[x] == 1:
			c1 += 1
		elif count[x] > 2:
			res += 1
	print(res + c1 // 2)


t = int(input())
for i in range(t):
	s = input()
	d = 0
	f = 0
	for j in range(len(s)):
		k1 = s.count(s[j])
		count = 0
		for k in range(j - 1, -1, -1):
			if s[j] == s[k]:
				count = 1
		if count == 0:
			if k1 >= 2:
				d += 1
			else:
				f += 1
	if f % 2 == 0:
		print(d + f // 2)
	else:
		print(d + (f - 1) // 2)


import os
import sys
from io import BytesIO, IOBase
from math import log2, ceil, sqrt, gcd, log
from itertools import permutations, combinations
from collections import *
from bisect import *
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
g = lambda : input().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
rr = lambda x: reversed(range(x))
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	k = 2
	a = g()
	n = len(a)
	f = {}
	for i in range(n):
		if a[i] not in f:
			f[a[i]] = []
		f[a[i]].append(i)
	sm = 0
	for v in f:
		sm += min(len(f[v]), k)
	sm = sm // k
	print(sm)


t = int(input())
for i in range(t):
	s = input()
	mp = {}
	lst = []
	uniq = 0
	ans = 0
	if len(s) == 1:
		print(0)
	else:
		for i in range(len(s)):
			if s[i] not in mp.keys():
				mp[s[i]] = 1
				lst.append(s[i])
			else:
				mp[s[i]] += 1
		if len(mp) == 1:
			print(1)
		else:
			for i in range(len(lst)):
				if mp[lst[i]] > 1:
					ans += 1
				else:
					uniq += 1
			ans += uniq // 2
			print(ans)


test = int(input())
for i in range(test):
	word = input()
	total = 0
	count = 0
	dict = {i: word.count(i) for i in word}
	for (i, j) in dict.items():
		if j >= 2:
			total += 1
		else:
			count += 1
	total += count // 2
	print(total)


for _ in range(int(input())):
	string = input()
	dic = {}
	for i in string:
		dic[i] = dic.get(i, 0) + 1
	val = dic.values()
	count = 0
	for i in val:
		if i <= 2:
			count = count + i
		else:
			count = count + 2
	print(count // 2)


a = int(input())
for i in range(a):
	kol = 0
	kolpol = 0
	s = input()
	slov = {}
	for j in range(len(s)):
		if slov.get(s[j]) == None:
			slov[s[j]] = 1
		elif slov.get(s[j]) == 1:
			slov[s[j]] = 2
	for k in slov.keys():
		if slov[k] == 2:
			kol += 1
		else:
			kolpol += 1
	kol += kolpol // 2
	print(kol)


import math
import sys
import collections
import bisect
import time
import random
from itertools import permutations

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	string = list(get_string())
	count = 0
	counter = collections.Counter(string)
	for i in counter:
		val = counter[i]
		if val == 1:
			count += 1
		else:
			count += 2
	print(count // 2)


from __future__ import division, print_function
import math
import sys
import os
from io import BytesIO, IOBase
from collections import deque, Counter, OrderedDict, defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input().strip()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
for _ in range(inp()):
	s = insr()
	g = Counter(s)
	cnt = 0
	for each in g:
		if g[each] >= 2:
			cnt += 1
	sec = 0
	for each in g:
		if g[each] == 1:
			sec += 1
	print(cnt + sec // 2)


from collections import Counter
t = int(input())
while t:
	s = str(input())
	l = dict(Counter(s))
	c1 = 0
	c2 = 0
	for (k, v) in l.items():
		if l[k] >= 2:
			c2 += 1
		else:
			c1 += 1
	print(c2 + c1 // 2)
	t -= 1