You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.

In one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the previous letter in the Latin alphabet for $s_i$. For example, the previous letter for b is a, the previous letter for s is r, the letter a has no previous letters. Note that after each removal the length of the string decreases by one. So, the index $i$ should satisfy the condition $1 \le i \le |s|$ during each operation.

For the character $s_i$ adjacent characters are $s_{i-1}$ and $s_{i+1}$. The first and the last characters of $s$ both have only one adjacent character (unless $|s| = 1$).

Consider the following example. Let $s=$ bacabcab.  During the first move, you can remove the first character $s_1=$ b because $s_2=$ a. Then the string becomes $s=$ acabcab.  During the second move, you can remove the fifth character $s_5=$ c because $s_4=$ b. Then the string becomes $s=$ acabab.  During the third move, you can remove the sixth character $s_6=$'b' because $s_5=$ a. Then the string becomes $s=$ acaba.  During the fourth move, the only character you can remove is $s_4=$ b, because $s_3=$ a (or $s_5=$ a). The string becomes $s=$ acaa and you cannot do anything with it. 

Your task is to find the maximum possible number of characters you can remove if you choose the sequence of operations optimally.


-----Input-----

The first line of the input contains one integer $|s|$ ($1 \le |s| \le 100$) — the length of $s$.

The second line of the input contains one string $s$ consisting of $|s|$ lowercase Latin letters.


-----Output-----

Print one integer — the maximum possible number of characters you can remove if you choose the sequence of moves optimally.


-----Examples-----
Input
8
bacabcab

Output
4

Input
4
bcda

Output
3

Input
6
abbbbb

Output
5



-----Note-----

The first example is described in the problem statement. Note that the sequence of moves provided in the statement is not the only, but it can be shown that the maximum possible answer to this test is $4$.

In the second example, you can remove all but one character of $s$. The only possible answer follows.  During the first move, remove the third character $s_3=$ d, $s$ becomes bca.  During the second move, remove the second character $s_2=$ c, $s$ becomes ba.  And during the third move, remove the first character $s_1=$ b, $s$ becomes a.

Difficulty: MEDIUM_HARD

Solutions:
n = int(input())
str = input()
lst = list(str)
for i in range(122, 97, -1):
	for k in range(100):
		l = len(lst)
		tmp = []
		for j in range(l):
			if ord(lst[j]) == i:
				if j + 1 < l and ord(lst[j + 1]) == i - 1 or (j - 1 >= 0 and ord(lst[j - 1]) == i - 1):
					tmp.append(j)
					bul = True
		l = len(tmp)
		tmp.reverse()
		for j in tmp:
			del lst[j]
print(n - len(lst))


n = int(input())
s = input()
s = '!' + s + '!'
cnt = 0
if n > 1:
	for char in range(ord('z'), ord('a') - 1, -1):
		i = 0
		while len(s) > 0 and i < len(s):
			if i == 0:
				if s[i] == chr(char) and s[i] == chr(ord(s[i + 1]) + 1):
					s = s[:i] + s[i + 1:]
					cnt += 1
					i = 0
			elif i == len(s) - 1:
				if s[i] == chr(char) and s[i] == chr(ord(s[i - 1]) + 1):
					s = s[:i] + s[i + 1:]
					cnt += 1
					i = 0
			elif s[i] == chr(char) and (s[i] == chr(ord(s[i + 1]) + 1) or s[i] == chr(ord(s[i - 1]) + 1)):
				s = s[:i] + s[i + 1:]
				cnt += 1
				i = 0
			i += 1
print(cnt)


n = int(input())
S = ['#'] + list(input()) + ['#']
ANS = 0
for i in range(25, -1, -1):
	j = 0
	while j < len(S):
		if j < len(S) and ord(S[j]) - 97 == i and (ord(S[j - 1]) - 97 == i - 1 or ord(S[j + 1]) - 97 == i - 1):
			ANS += 1
			S.pop(j)
			j -= 1
		else:
			j += 1
print(ANS)


import re
n = int(input())
s = input()
y = 'z'
for i in range(121, 96, -1):
	x = y + '*'
	y = chr(i)
	s = re.sub(x + y + x, y, s)
print(n - len(s))


from os import path
from sys import stdin, stdout
if path.exists('inp.txt'):
	stdin = open('inp.txt', 'r')

def io():
	return stdin.readline()
maxn = 100005
ans = 0
q = int(io())
inp = io().split()
s = inp[0]
for i in range(25, 0, -1):
	check = 1
	while check:
		check = 0
		for j in range(len(s)):
			if j >= len(s):
				break
			if ord(s[j]) - ord('a') == i and j + 1 < len(s) and (ord(s[j + 1]) - ord('a') == i - 1):
				s = s[0:j] + s[j + 1:]
				ans += 1
				check = 1
			elif ord(s[j]) - ord('a') == i and j > 0 and (ord(s[j - 1]) - ord('a') == i - 1):
				s = s[0:j] + s[j + 1:]
				ans += 1
				check = 1
print(ans)


n = int(input())
a = list(input())
for i in range(25, 0, -1):
	cur = chr(97 + i)
	prev = chr(96 + i)
	j = 0
	while True:
		if j >= len(a):
			break
		x = j - 1 if j != 0 else j
		y = j + 1 if j != len(a) - 1 else j
		if a[j] == cur and (a[x] == prev or a[y] == prev):
			a.pop(j)
			j -= 1
		j += 1
	j = len(a) - 1
	while j >= 0:
		x = j - 1 if j != 0 else j
		y = j + 1 if j != len(a) - 1 else j
		if a[j] == cur and (a[x] == prev or a[y] == prev):
			a.pop(j)
			j += 1
		j -= 1
print(n - len(a))


n = int(input())
s = input()
rm = 0
while True:
	new_s = []
	n = len(s)
	rm_ls = []
	for i in range(n):
		nb = (max(0, i - 1), min(n - 1, i + 1))
		if s[nb[0]] == chr(ord(s[i]) - 1) or s[nb[1]] == chr(ord(s[i]) - 1):
			rm_ls.append(i)
	if rm_ls:
		mx = max(zip(map(lambda x: s[x], rm_ls), rm_ls))[1]
	else:
		break
	new_s = s[:mx] + s[mx + 1:]
	rm += 1
	s = new_s
	if new_s == '':
		break
print(rm)


def MaxActions(strin):
	if strin:
		cleard = 0
		peak = max(strin)
		start = strin.find(peak)
		while start != -1:
			group = 0
			remember = False
			end = start
			while end < len(strin) and strin[end] == peak:
				end += 1
			if start != 0 and ord(strin[start - 1]) + 1 == ord(peak) or (end != len(strin) and ord(strin[end]) + 1 == ord(peak)):
				cleard += end - start
				strin = strin[:start] + strin[end:]
				end = start
			start = strin.find(peak, end)
		return cleard + sum(map(MaxActions, strin.split(peak)))
	else:
		return 0
assert MaxActions('bacabcab') == 4
assert MaxActions('bcda') == 3
assert MaxActions('abbbbb') == 5
count = input()
cities = input()
print(MaxActions(cities))


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi, ceil, log, inf
from itertools import permutations
from copy import deepcopy
from heapq import *
from sys import setrecursionlimit

def main():
	n = int(input())
	a = list(map(lambda x: ord(x) - 97, input().rstrip()))
	if n == 1:
		print(0)
	else:
		for i in sorted(set(a), reverse=True):
			j = 0
			while j < len(a):
				f = 1
				if a[j] == i:
					if j == 0 and len(a) != 1:
						if a[0] - 1 == a[1]:
							a.pop(0)
					elif j == len(a) - 1:
						if a[j] - 1 == a[j - 1]:
							a.pop()
					elif j > 0 and j < len(a) - 1:
						if a[j] - 1 == a[j + 1] or a[j - 1] == a[j] - 1:
							f = 0
							a.pop(j)
				j = j + 1 if f else -1
		print(n - len(a))
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')
main()


import re
a = 'yxwvutsrqponmlkjihgfedcba'
n = int(input())
s = input()
for (x, y) in zip('z' + a, a):
	t = x + '*' + y + x + '*'
	s = re.sub(x + t + '|' + t + x, y, s)
print(n - len(s))


def removeadj(l):
	removes = 0
	while 1:
		maxE = 1
		maxI = -1
		if len(l) == 1:
			print(removes)
			return
		for i in range(len(l)):
			check = False
			if i == 0:
				if l[i] == l[i + 1] + 1:
					check = True
			if i == len(l) - 1:
				if l[i] == l[i - 1] + 1:
					check = True
			elif l[i] == l[i - 1] + 1 or l[i] == l[i + 1] + 1:
				check = True
			if check:
				if l[i] > maxE:
					maxE = l[i]
					maxI = i
		if maxI == -1:
			print(removes)
			return
		else:
			del l[maxI]
			removes += 1
n = int(input())
s = input()
l = [ord(i) - 96 for i in s]
removeadj(l)


n = int(input())
s = input()
max_c = 0
while max_c != -1:
	max_c = -1
	idx = -1
	for i in range(len(s)):
		if i < len(s) - 1:
			if ord(s[i + 1]) + 1 == ord(s[i]) and ord(s[i]) > max_c:
				max_c = ord(s[i])
				idx = i
		if i > 0:
			if ord(s[i - 1]) + 1 == ord(s[i]) and ord(s[i]) > max_c:
				max_c = ord(s[i])
				idx = i
	if max_c != -1:
		s = s[:idx] + s[idx + 1:]
print(n - len(s))


n = int(input())
s = input()
s = list(s)
for i in range(97 + 26, 97, -1):
	c = chr(i)
	k = []
	for j in range(len(s)):
		if j - 1 >= 0 and s[j - 1] == chr(i - 1) and (s[j] == c):
			k.append(j)
			l = j + 1
			while l < len(s) and s[l] == s[j]:
				k.append(l)
				l += 1
		elif j + 1 < len(s) and s[j + 1] == chr(i - 1) and (s[j] == c):
			k.append(j)
			l = j - 1
			while l >= 0 and s[l] == s[j]:
				k.append(l)
				l -= 1
	now = []
	for j in range(len(s)):
		if j not in k:
			now.append(s[j])
	s = now.copy()
print(n - len(s))


n = int(input())
s = input()
s_nums = [ord(s[i]) for i in range(n)]
ans = 0
for biggest_number in range(ord('z'), ord('a'), -1):
	to_delete = [False for _ in range(len(s_nums))]
	for j in range(len(s_nums)):
		if s_nums[j] == biggest_number:
			if len(s_nums) == 1:
				pass
			elif j == 0:
				if s_nums[j + 1] == biggest_number - 1:
					to_delete[j] = True
			elif j == len(s_nums) - 1:
				if s_nums[j - 1] == biggest_number - 1 or to_delete[j - 1]:
					to_delete[j] = True
			elif s_nums[j - 1] == biggest_number - 1 or s_nums[j + 1] == biggest_number - 1 or to_delete[j - 1]:
				to_delete[j] = True
	for j in range(len(s_nums) - 1, -1, -1):
		if s_nums[j] == biggest_number:
			if len(s_nums) == 1:
				pass
			elif j == 0:
				if s_nums[j + 1] == biggest_number - 1 or to_delete[j + 1]:
					to_delete[j] = True
			elif j == len(s_nums) - 1:
				if s_nums[j - 1] == biggest_number - 1 or to_delete[j - 1]:
					to_delete[j] = True
			elif s_nums[j - 1] == biggest_number - 1 or s_nums[j + 1] == biggest_number - 1 or to_delete[j + 1]:
				to_delete[j] = True
	count_deleted = 0
	len_s_nums_before = len(s_nums)
	for j in range(len_s_nums_before):
		if to_delete[j]:
			s_nums = s_nums[:j - count_deleted] + s_nums[j + 1 - count_deleted:]
			ans += 1
			count_deleted += 1
print(ans)


import string
n = int(input())
s = input()
ls = []
alps = []
for a in s:
	ls.append(a)
for a in string.ascii_lowercase:
	alps.append(a)
alps.reverse()
ctr = 0
for i in range(25):
	j = 0
	while j < len(ls) and len(ls) > 1:
		if alps[i] == ls[j]:
			for oo in range(1):
				if j != 0 and j != len(ls) - 1:
					if alps[i + 1] == ls[j + 1] or alps[i + 1] == ls[j - 1]:
						ls.pop(j)
						ctr += 1
						j = -1
						break
				if j == 0:
					if alps[i + 1] == ls[j + 1]:
						ls.pop(j)
						ctr += 1
						j = -1
						break
				if j == len(ls) - 1:
					if alps[i + 1] == ls[j - 1]:
						ls.pop(j)
						ctr += 1
						j = -1
						break
		j += 1
print(ctr)


t = int(input())
s = input()
ans = ''
count = 0
while True:
	flag = True
	j = -1
	ch = 0
	for i in range(len(s)):
		if i != 0 and ord(s[i - 1]) - ord(s[i]) == -1 or (i != len(s) - 1 and ord(s[i + 1]) - ord(s[i]) == -1):
			if j == -1 or ord(ch) < ord(s[i]):
				ch = s[i]
				j = i
				flag = False
	if flag:
		break
	s = s[:j] + s[j + 1:len(s)]
	count += 1
print(count)


import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List
sys.setrecursionlimit(99999)
n = int(input())
s = input()
sl = string.ascii_lowercase[::-1]
for i in range(25):
	sp = sl[i:i + 2]
	while sp in s:
		s = s.replace(sp, sl[i + 1])
	sp = sp[::-1]
	while sp in s:
		s = s.replace(sp, sl[i + 1])
print(n - len(s))


n = int(input())
s = list(input())
k = 0
ans = 0
while k == 0:
	k = 1
	num = []
	for i in range(1, len(s)):
		if ord(s[i]) - 1 == ord(s[i - 1]):
			k = 0
			num.append([ord(s[i]), i])
		elif ord(s[i]) + 1 == ord(s[i - 1]):
			k = 0
			num.append([ord(s[i - 1]), i - 1])
	if num:
		num.sort()
		ans += 1
		index = num[-1][1]
		s.pop(index)
print(ans)


import re
from collections import Counter
n = int(input())
s = input()[:n]
letters = Counter(s)
for x in sorted(letters, reverse=True):
	if x == 'a':
		continue
	prev = chr(ord(x) - 1)
	s = re.sub(x + '+' + prev, prev, s)
	s = re.sub(prev + x + '+', prev, s)
print(n - len(s))


def go():
	n = int(input())
	s = list(map(ord, input()))
	letters = sorted(set(s), reverse=True)
	for l in letters:
		l1 = l - 1
		if l - 1 not in letters:
			continue
		i = 0
		while i < len(s):
			if s[i] != l1:
				i += 1
			elif i > 0 and s[i - 1] == l:
				del s[i - 1]
				i -= 1
			elif i < len(s) - 1 and s[i + 1] == l:
				del s[i + 1]
			else:
				i += 1
	return n - len(s)
print(go())


n = input()
string = input()
lastString = string
go = True
removed = 0

def removeChar(s):
	index = 0
	found = False
	for i in range(len(s)):
		if (ord(s[i]) > ord(s[index]) or found == False) and (i > 0 and ord(s[i]) - ord(s[i - 1]) == 1 or (i < len(s) - 1 and ord(s[i]) - ord(s[i + 1]) == 1)):
			index = i
			found = True
	if found == True:
		s = s[:index] + s[index + 1:]
	return s
while go == True:
	string = removeChar(string)
	if string == lastString:
		go = False
	else:
		lastString = string
		removed += 1
print(removed)


n = int(input())
s = list(input())
d = {}
alp = 'abcdefghijklmnopqrstuvwxyz'
c = 0
for i in range(26):
	d[alp[i]] = i
l = []
mi = d[s[0]]
for i in range(n):
	l.append(d[s[i]])
	if l[i] < mi:
		mi = l[i]
idx = 25
while idx != 0:
	if len(l) == 1:
		break
	else:
		while True:
			count = 0
			for i in range(len(l)):
				if l[i] == idx:
					if i == 0:
						if l[1] == idx - 1:
							l.pop(i)
							count += 1
							break
					elif i == len(l) - 1:
						if l[len(l) - 2] == idx - 1:
							l.pop(i)
							count += 1
							break
					elif l[i + 1] == idx - 1 or l[i - 1] == idx - 1:
						l.pop(i)
						count += 1
						break
			if count == 0:
				break
		idx -= 1
print(n - len(l))


n = int(input())
s = input()
l = []
for i in range(n):
	t = ord(s[i])
	if t not in l:
		l.append(t)
l.sort(reverse=True)
c = 0
while len(l) > 1:
	j = 0
	f = False
	while j < len(s):
		if ord(s[j]) == l[0]:
			if j == 0:
				if ord(s[1]) == l[0] - 1:
					s = s[1:]
					c += 1
					f = True
				else:
					j += 1
			elif j == len(s) - 1:
				if ord(s[len(s) - 2]) == l[0] - 1:
					s = s[:len(s) - 1]
					c += 1
					f = True
				else:
					j += 1
			elif ord(s[j + 1]) == l[0] - 1 or ord(s[j - 1]) == l[0] - 1:
				s = s[:j] + s[j + 1:]
				c += 1
				f = True
			else:
				j += 1
		else:
			j += 1
	if not f:
		l.pop(0)
print(c)


import sys, math
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
t = 1
for tt in range(t):
	n = inp()
	b = insr()
	a = [100] + [ord(i) - 97 for i in b] + [100]
	q = [i for i in range(26, -1, -1)]
	for i in q:
		j = 1
		while j < len(a) - 1:
			if a[j] == i:
				if a[j] == a[j - 1] + 1 or a[j] == a[j + 1] + 1:
					a.pop(j)
					j = 1
				else:
					j += 1
			else:
				j += 1
	print(n + 2 - len(a))


import sys
input = sys.stdin.buffer.readline

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

def sieve(n):
	a = [1] * n
	for i in range(2, n):
		if a[i]:
			for j in range(i * i, n, i):
				a[j] = 0
	return a
n = int(input())
l = list(input())[:n]
if n >= 1:
	while len(l) > 1:
		a = 0
		idx = -1
		f = False
		if l[0] - 1 == l[1]:
			f = 1
			idx = 0
			a = l[0]
			idx = 0
		for i in range(1, len(l) - 1):
			if l[i] - l[i - 1] == 1 or l[i] - l[i + 1] == 1:
				f = True
				if l[i] > a:
					a = max(a, l[i])
					idx = i
		if l[-1] - l[-2] == 1:
			f = True
			if l[-1] > a:
				a = max(a, l[-1])
				idx = -1
		if not f:
			break
		l.pop(idx)
print(n - len(l))


def i():
	return input()

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

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

def liis():
	return list(map(int, input().split()))
n = int(input())
s = input()
a = []
for i in range(len(s)):
	a.append(s[i])
a = sorted(a)[::-1]
count = 0
todos = set()
for c in a:
	for j in range(n):
		for i in range(len(s)):
			if s[i] == c and (i > 0 and ord(s[i - 1]) == ord(s[i]) - 1 or (i < len(s) - 1 and ord(s[i + 1]) == ord(s[i]) - 1)):
				s = s[:i] + s[i + 1:]
				count += 1
				break
print(count)


lengthofstring = int(input())
string1 = [ord(k) - 97 for k in input()]
traverse1 = list(range(26))
traverse1 = traverse1[::-1] + []
maxinstring = max(string1)
answer = 0
for k in range(26):
	letter = traverse1[k]
	if letter <= maxinstring:
		cv = 0
		while cv <= len(string1) - 1 and len(string1) >= 2:
			if string1[cv] == letter:
				if cv >= 1 and cv <= len(string1) - 2:
					if string1[cv - 1] == letter - 1 or string1[cv + 1] == letter - 1:
						string1.pop(cv)
						answer += 1
					else:
						cv += 1
				elif cv == 0:
					if string1[cv + 1] == letter - 1:
						string1.pop(cv)
						answer += 1
					else:
						cv += 1
				elif cv == len(string1) - 1:
					if string1[cv - 1] == letter - 1:
						string1.pop(cv)
						answer += 1
					else:
						cv += 1
				else:
					cv += 1
			else:
				cv += 1
		cv1 = len(string1) - 1
		while cv1 >= 0 and len(string1) >= 2:
			if string1[cv1] == letter:
				if cv1 >= 1 and cv1 <= len(string1) - 2:
					if string1[cv1 - 1] == letter - 1 or string1[cv1 + 1] == letter - 1:
						string1.pop(cv1)
						answer += 1
					else:
						cv1 += -1
				elif cv1 == 0:
					if string1[cv1 + 1] == letter - 1:
						string1.pop(cv1)
						answer += 1
					else:
						cv1 += -1
				elif cv == len(string1) - 1:
					if string1[cv1 - 1] == letter - 1:
						string1.pop(cv1)
						answer += 1
					else:
						cv1 += -1
				else:
					cv1 += -1
			else:
				cv1 += -1
print(answer)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

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
from collections import defaultdict
from heapq import heappop, heappush, heapify
n = int(input())
s = list(input())
hash = defaultdict(bool)
ans = 0
for i in range(123, 96, -1):
	z = chr(i)
	if z != 'a':
		z1 = chr(i - 1)
		for j in range(len(s)):
			if s[j] == z:
				flag = 0
				for k in range(j - 1, -1, -1):
					if hash[k] == True:
						pass
					elif s[k] == z1:
						hash[j] = True
						flag = 1
						ans += 1
						break
					elif s[k] == z:
						pass
					else:
						break
				if not flag:
					for k in range(j + 1, len(s)):
						if hash[k] == True:
							pass
						elif s[k] == z1:
							hash[j] = True
							ans += 1
							flag = 1
							break
						elif s[k] == z:
							pass
						else:
							break
print(ans)


def is_right_less(s, i):
	return i + 1 < len(s) and ord(s[i]) - ord(s[i + 1]) == 1

def is_left_less(s, i):
	return i - 1 >= 0 and ord(s[i]) - ord(s[i - 1]) == 1

def sort_dict(p: dict) -> dict:
	temp = {k: v for (k, v) in sorted(p.items(), key=lambda item: item[1])}
	x = list(temp.items())
	x.reverse()
	return {k: v for (k, v) in x}

def check_neighbours(s, i):
	if is_left_less(s, i) or is_right_less(s, i):
		return i
	else:
		return -1

def remove_neighbors(s: str) -> int:
	s = list(s)
	removed = 0
	while len(s) != 0:
		candidates = {}
		for j in range(len(s)):
			c = check_neighbours(s, j)
			if c >= 0:
				candidates[c] = s[c]
		candidates = sort_dict(candidates)
		if len(candidates) > 0:
			s.pop(list(candidates.items())[0][0])
			removed += 1
		else:
			break
	return removed
len_s = int(input())
s = input()
print(remove_neighbors(s))


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

class Node:

	def __init__(self, char):
		self.val = ord(char)
		self.next = None
		self.prev = None

	def remove(self):
		self.prev.next = self.next
		if self.next:
			self.next.prev = self.prev

	def check(self, itr):
		if itr != self.val - ord('a'):
			return
		tmp = -1 if not self.next else self.next.val
		if self.val - 1 in [self.prev.val, tmp]:
			self.remove()
			self.prev.check(itr)

class Deq:

	def __init__(self):
		self.head = Node('*')
		self.tail = self.head

	def add(self, char):
		curr = Node(char)
		self.tail.next = curr
		curr.prev = self.tail
		self.tail = curr

	def print(self):
		s = ''
		curr = self.head.next
		while curr:
			s += chr(curr.val)
			curr = curr.next
		print(s)

	def size(self):
		cnt = 0
		curr = self.head.next
		while curr:
			cnt += 1
			curr = curr.next
		return cnt

def put():
	return map(int, input().split())
n = int(input())
ans = 0
d = Deq()
for i in input().strip():
	d.add(i)
for i in range(25, 0, -1):
	for j in range(1):
		curr = d.head.next
		while curr:
			curr.check(i)
			curr = curr.next
print(n - d.size())


n = int(input())
s = input().strip()
ans = 0
for i in range(26):
	c = chr(122 - i)
	f = True
	while f:
		f = False
		n = len(s)
		for i in range(n):
			if s[i] == c:
				if i > 0 and ord(s[i]) - ord(s[i - 1]) == 1 or (i < n - 1 and ord(s[i]) - ord(s[i + 1]) == 1):
					f = True
					ans += 1
					s = s[:i] + s[i + 1:n]
					break
print(ans)


from math import factorial
from collections import Counter
from heapq import heapify, heappop, heappush
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')

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

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')
import bisect
A = ord('a')

def main():
	n = N()
	s = list(input())
	le = len(s)

	def cp(a, b):
		if abs(ord(a) - ord(b)) == 1:
			return True
		return False
	for c in range(26, 0, -1):
		for i in range(len(s) - 1, -1, -1):
			if ord(s[i]) - A + 1 == c:
				(l, r) = (i - 1, i + 1)
				while l > -1 and i < len(s) and (ord(s[i]) - A + 1 == c) and cp(s[i], s[l]):
					s.pop(i)
					l = i - 1
				while r < len(s) and ord(s[i]) - A + 1 == c and (i < len(s)) and cp(s[i], s[r]):
					s.pop(i)
					r = i + 1
	print(le - len(s))
main()


n = int(input())
s = input()
now = ord('z')
st = ord('a')
tong = []
for i in range(144):
	tong.append(0)
for c in s:
	tong[ord(c)] += 1
ans = 0
while now > st:
	pd = 0
	while 1:
		pd = 0
		i = 0
		while i < len(s):
			if ord(s[i]) == now and (i - 1 >= 0 and ord(s[i - 1]) == now - 1 or (i + 1 < len(s) and ord(s[i + 1]) == now - 1)):
				s = s[0:i] + s[i + 1:len(s)]
				tong[now] -= 1
				pd = 1
				ans += 1
			i += 1
		if pd == 0:
			break
	now -= 1
print(ans)


from collections import deque, defaultdict
from math import sqrt, ceil, factorial, floor, inf, log2, sqrt, gcd
import bisect
import sys
import copy

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

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

def input():
	return sys.stdin.readline().strip()
n = int(input())
s = input()
arr = []
for i in range(len(s)):
	arr.append(ord(s[i]))
cnt = 0
for j in range(122, 96, -1):
	while True:
		x = j
		i = 0
		flag = 0
		while i < len(arr) and len(arr) > 1:
			if i == 0:
				if arr[i] == x and arr[i + 1] == x - 1:
					arr.pop(i)
					cnt += 1
					flag = 1
					break
			if i == len(arr) - 1:
				if arr[i] == x and arr[i - 1] == x - 1:
					arr.pop(i)
					cnt += 1
					flag = 1
					break
			elif arr[i] == x and (arr[i - 1] == x - 1 or arr[i + 1] == x - 1):
				arr.pop(i)
				cnt += 1
				flag = 1
				break
			if flag == 1:
				break
			i += 1
		if flag == 0:
			break
print(cnt)


n = int(input())
s = input()
res = 0
for _ in range(n):
	(max_char, max_index) = ('A', -1)
	for i in range(len(s)):
		is_ok = False
		if i > 0 and ord(s[i]) == ord(s[i - 1]) + 1:
			is_ok = True
		if i < len(s) - 1 and ord(s[i]) == ord(s[i + 1]) + 1:
			is_ok = True
		if is_ok and s[i] >= max_char:
			max_index = i
			max_char = s[i]
	if max_index > -1:
		s = s[:max_index] + s[max_index + 1:]
		res += 1
	else:
		break
print(res)


import sys
import math
import heapq
import collections
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

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

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')

def printspace(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer(' ')

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
n = inputnum()
s = [ord(x) - ord('a') for x in input()]
t = sorted(s, reverse=True)
for i in t:
	l = len(s)
	if l == 1:
		break
	for j in range(l):
		if s[j] == i:
			if j == 0:
				if abs(s[1] - i) == 1:
					s.pop(j)
					break
			elif j == l - 1:
				if abs(s[l - 2] - i) == 1:
					s.pop(j)
					break
			elif abs(s[j - 1] - i) == 1 or abs(s[j + 1] - i) == 1:
				s.pop(j)
				break
print(n - len(s))


def reducable(s):
	rc = None
	mx = 'a'
	for (i, c) in enumerate(s):
		if i - 1 >= 0 and ord(c) - ord(s[i - 1]) == 1 or (i + 1 < len(s) and ord(c) - ord(s[i + 1]) == 1):
			if c > mx:
				mx = c
				rc = i
	return rc
n = int(input())
s = list(input())
idx = reducable(s)
ans = 0
while idx != None:
	del s[idx]
	ans += 1
	idx = reducable(s)
print(ans)


n = int(input())
s = input()
i = 0
a = 'a'
ind = -1
f = True
while f:
	ind = -1
	a = 'a'
	i = 0
	while i < len(s):
		if i == 0:
			if len(s) >= 2:
				if ord(s[i]) == ord(s[i + 1]) + 1:
					if ord(a) < ord(s[i]):
						a = s[i]
						ind = i
		elif i == len(s) - 1 and len(s) >= 2:
			if ord(s[i]) == ord(s[i - 1]) + 1:
				if ord(a) < ord(s[i]):
					a = s[i]
					ind = i
		elif ord(s[i]) == ord(s[i - 1]) + 1 or ord(s[i]) == ord(s[i + 1]) + 1:
			if ord(a) < ord(s[i]):
				a = s[i]
				ind = i
		i += 1
	if ind != -1:
		if ind + 1 != len(s):
			s = s[0:ind] + s[ind + 1:]
		else:
			s = s[0:ind]
	else:
		f = False
print(n - len(s))


n = int(input())
s = input()
if n == 1:
	print(0)
	exit()
for i in range(122, 96, -1):
	for k in range(len(s)):
		arr = []
		for j in range(len(s)):
			c = chr(i)
			if j == 0 and ord(s[j + 1]) + 1 == ord(s[j]) == i:
				arr += [j]
			elif j == len(s) - 1 and ord(s[j - 1]) + 1 == ord(s[j]) == i:
				arr += [j]
			elif j != 0 and j != len(s) - 1 and (ord(s[j + 1]) + 1 == ord(s[j]) == i or ord(s[j - 1]) + 1 == ord(s[j]) == i):
				arr += [j]
		new = ''
		for j in range(len(s)):
			if j in arr:
				continue
			new += s[j]
		s = new
		if len(s) == 1:
			break
	if len(s) == 1:
		break
print(n - len(s))


n = int(input())
s = list(input())

def recursion(s, target=chr(ord('a') + 25)):
	if target == 'a':
		return 0
	else:
		count = 0
		stack = []
		hunterr = chr(ord(target) - 1)
		for i in s:
			if not stack:
				stack.append(i)
			elif i == hunterr and stack[-1] == target:
				while stack and stack[-1] == target:
					stack.pop()
					count += 1
				stack.append(i)
			elif i == target and stack[-1] == hunterr:
				count += 1
			else:
				stack.append(i)
		return count + recursion(stack, hunterr)
print(recursion(s))


N = int(input())
S = list(input())
res = 0
for i in range(26):
	idx = 0
	found = True
	while found:
		found = False
		while idx < len(S):
			if S[idx] == chr(ord('z') - i):
				if idx + 1 < len(S) and ord(S[idx]) - ord(S[idx + 1]) == 1 or (idx - 1 >= 0 and ord(S[idx]) - ord(S[idx - 1]) == 1):
					S.pop(idx)
					res += 1
					found = True
				else:
					idx += 1
			else:
				idx += 1
		idx = 0
print(res)


import sys
I = lambda : int(input())
readline = lambda : sys.stdin.readline().strip('\n')
RM = readmap = lambda x=int: map(x, readline().split(' '))
(n, s) = (I(), readline())
for i in range(25, 0, -1):
	y = chr(ord('a') + i)
	x = chr(ord('a') + i - 1)
	while True:
		temp = len(s)
		s = s.replace(x + y, x).replace(y + x, x)
		if len(s) == temp:
			break
print(n - len(s))
quit()
d = {}
for (i, x) in zip(range(I()), RM()):
	d[x - i] = d.get(x - i, 0) + x
print(max(d.values()))
quit()
(n, a, b) = (I(), [*RM()], [*RM()])
(count1, count2) = (0, 0)
for (i, j) in zip(a, b):
	count1 += i & ~j
	count2 += j & ~i
print(divmod(count2, count1)[0] + 1 if count1 else -1)


n = int(input())
s = input()
for i in range(25):
	ch = chr(ord('z') - i)
	prev = chr(ord(ch) - 1)
	j = 0
	while j < len(s):
		if s[j] == ch and (j - 1 >= 0 and s[j - 1] == prev or (j + 1 < len(s) and s[j + 1] == prev)):
			s = s[:j] + s[j + 1:]
			j = 0
		else:
			j += 1
print(n - len(s))


n = int(input())
s = input()
alpha = 'abcdefghijklmnopqrstuvwxyz'
count = 0
while len(s) > 1:
	for j in range(len(alpha) - 1, 0, -1):
		if len(s) == 1:
			break
		ele = alpha[j - 1] + alpha[j]
		while ele in s or ele[::-1] in s:
			i = 0
			while i < len(s):
				if s[i] == alpha[j]:
					if i == 0 and s[i + 1] == alpha[j - 1]:
						count += 1
						s = s[1:]
					elif i == len(s) - 1:
						if s[i - 1] == alpha[j - 1]:
							count += 1
							s = s[:len(s) - 1]
					elif s[i + 1] == alpha[j - 1] or s[i - 1] == alpha[j - 1]:
						count += 1
						s = s[:i] + s[i + 1:]
				i += 1
	v1 = 0
	for i in range(len(s) - 1):
		if abs(ord(s[i]) - ord(s[i + 1])) == 1:
			v1 += 1
	if v1 == 0:
		break
print(count)


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
n = int(input())
s = [ord(c) for c in input()]
ans = 0
code = 122
while code >= 97:
	toDel = []
	k = len(s)
	for (i, c) in enumerate(s):
		if c != code:
			continue
		if i > 0 and s[i - 1] + 1 == code:
			toDel.append(i - len(toDel))
		elif i < k - 1 and s[i + 1] + 1 == code:
			toDel.append(i - len(toDel))
	if toDel:
		for i in toDel:
			del s[i]
			ans += 1
	else:
		code -= 1
print(ans)


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

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

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	n = II()
	s = SI()
	aa = [100] + [ord(c) - 97 for c in s] + [100]
	for code in range(25, 0, -1):
		i = 1
		while i < len(aa):
			if aa[i] == code and (aa[i - 1] == code - 1 or aa[i + 1] == code - 1):
				del aa[i]
				if aa[i] == code - 1:
					i -= 1
			else:
				i += 1
	print(n + 2 - len(aa))
main()


n = int(input())
string = input()
arr = list(string)
count = 0
if n == 1:
	print('0')
else:
	for i in range(122, 97, -1):
		lis = []
		counter = 0
		j = 0
		while j < len(arr):
			if len(arr) == 1:
				break
			if ord(arr[j]) == i:
				if j == 0:
					if ord(arr[j + 1]) == i - 1:
						count += 1
						arr.pop(j)
						if j > 0:
							j = j - 2
						else:
							j = j - 1
				elif j == len(arr) - 1:
					if ord(arr[j - 1]) == i - 1:
						count += 1
						arr.pop(j)
						if j > 0:
							j = j - 2
						else:
							j = j - 1
				elif ord(arr[j + 1]) == i - 1 or ord(arr[j - 1]) == i - 1:
					count += 1
					arr.pop(j)
					if j > 0:
						j = j - 2
					else:
						j = j - 1
			j += 1
	print(n - len(arr))


(n, s) = (int(input()), input())
for i in range(25):
	while 1:
		(ch, pch) = (chr(ord('z') - i), chr(ord('z') - i - 1))
		ns = ''
		for (p, c) in enumerate(s):
			if c == ch and (p > 0 and s[p - 1] == pch or (p < len(s) - 1 and s[p + 1] == pch)):
				continue
			ns += s[p]
		if s == ns:
			break
		s = ns
print(n - len(s))


import sys
import math
import functools

@functools.lru_cache(maxsize=None)
def sol(s):
	ans = 0
	i = 0
	while i < len(s):
		a = i > 0 and ord(s[i]) - ord(s[i - 1]) == 1
		b = i < len(s) - 1 and ord(s[i]) - ord(s[i + 1]) == 1
		if a or b:
			c = s[i]
			while i < len(s) - 1 and s[i + 1] == c:
				i += 1
			ans = max(ans, 1 + sol(s[:i] + s[i + 1:]))
		i += 1
	print(s, ans)
	return ans
n = int(sys.stdin.readline())
s = sys.stdin.readline()
ans = 0
for c in 'abcdefghijklmnopqrstuvwxyz'[::-1]:
	i = 0
	while i < len(s):
		if s[i] == c:
			if i > 0 and ord(s[i]) - ord(s[i - 1]) == 1 or (i < len(s) - 1 and ord(s[i]) - ord(s[i + 1]) == 1):
				s = s[:i] + s[i + 1:]
				ans += 1
				i = 0
			else:
				i += 1
		else:
			i += 1
print(ans)


def index_to_remove(s):
	n = len(s)
	char = ''
	index = -1
	for i in range(n):
		can_remove = False
		if i > 0:
			can_remove = ord(s[i]) - ord(s[i - 1]) == 1
		if not can_remove and i < n - 1:
			can_remove = ord(s[i]) - ord(s[i + 1]) == 1
		if can_remove:
			if s[i] > char:
				char = s[i]
				index = i
	return index
n = int(input())
s = list(input())
i = index_to_remove(s)
ans = 0
while i != -1:
	s.pop(i)
	ans += 1
	i = index_to_remove(s)
print(ans)


n = int(input())
s = input()
for maxElement in sorted(list(s), reverse=True):
	prev = chr(ord(maxElement) - 1)
	edited = False
	for i in range(len(s)):
		if s[i] == maxElement:
			if i == 0 and i + 1 < len(s):
				if s[i + 1] == prev:
					s = s[i + 1:]
					edited = True
					break
			elif i == len(s) - 1 and i - 1 >= 0:
				if s[i - 1] == prev:
					s = s[:i]
					edited = True
					break
			elif i - 1 >= 0 and i + 1 < len(s):
				if s[i - 1] == prev or s[i + 1] == prev:
					s = s[:i] + s[i + 1:]
					edited = True
					break
print(n - len(s))


import re
n = int(input())
s = input()
for i in range(122, 97, -1):
	x = chr(i) + '*'
	y = chr(i - 1)
	s = re.sub(x + y + x, y, s)
print(n - len(s))


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

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

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
n = int(input())
a = list(input().strip())
res = 0
for i in reversed('abcdefghijklmnopqrstuvwxyz'):
	while True:
		f = 1
		b = []
		m = len(a)
		for j in range(m):
			if a[j] == i:
				if j != m - 1 and ord(i) - 1 == ord(a[j + 1]) or (j != 0 and ord(i) - 1 == ord(a[j - 1])):
					f = 0
					continue
			b.append(a[j])
		a = b[:]
		if f:
			break
print(n - len(a))


MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
let = '@abcdefghijklmnopqrstuvwxyz'
n = ii()
s = ls()
s = ['$'] + s + ['$']
for j in range(26, 0, -1):
	while 1:
		plen = len(s)
		for k in range(1, len(s)):
			if s[k] == let[j] and (s[k - 1] == let[j - 1] or s[k + 1] == let[j - 1]):
				s.pop(k)
				break
		currlen = len(s)
		if currlen == plen:
			break
print(n - len(s) + 2)


import string
n = int(input())
a = list(input())
for i in list(string.ascii_lowercase[::-1]):
	if i != 'a':
		j = 0
		while j != len(a):
			ch = False
			if len(a) > 1 and a[j] == i:
				if j != len(a) - 1:
					if a[j] == chr(ord(a[j + 1]) + 1):
						a[j] = ''
						ch = True
				if j != 0:
					if a[j] == chr(ord(a[j - 1]) + 1):
						a[j] = ''
						ch = True
				if ch:
					if j != 0:
						j -= 1
					j -= 1
				a = list(filter(lambda x: x != '', a))
			j += 1
print(n - len(a))


from collections import *
(n, s, d) = (int(input()), input(), deque())
for i in range(ord('z'), ord('a'), -1):
	for (c, j) in enumerate(s):
		if j == chr(i):
			if c < len(s) - 1 and s[c + 1] == chr(i - 1) or (d and d[-1] == chr(i - 1)):
				continue
			else:
				d.append(j)
		else:
			d.append(j)
	s = ''.join(d)[::-1]
	d = deque()
	for (c, j) in enumerate(s):
		if j == chr(i):
			if c < len(s) - 1 and s[c + 1] == chr(i - 1) or (d and d[-1] == chr(i - 1)):
				continue
			else:
				d.append(j)
		else:
			d.append(j)
	s = ''.join(d)
	d = deque()
print(n - len(s))


import sys

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

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	n = mint()
	i = 0
	s = [0] * n
	for c in minp():
		s[i] = ord(c) - ord('a')
		i += 1
	for c in range(25, 0, -1):
		i = 0
		while i < len(s):
			if s[i] == c and (i > 0 and s[i - 1] == c - 1 or (i + 1 < len(s) and s[i + 1] == c - 1)):
				s.pop(i)
				if i > 0:
					i -= 1
			else:
				i += 1
	print(n - len(s))
solve()


import copy

def function(s, c):
	flag = True
	while flag:
		ts = ''
		for i in range(len(s)):
			if s[i] == c:
				if s[max(0, i - 1)] == chr(ord(c) - 1) or s[min(len(s) - 1, i + 1)] == chr(ord(c) - 1):
					ts += ''
				else:
					ts += s[i]
			else:
				ts += s[i]
		if ts == s:
			flag = False
		else:
			s = ts
	return s
n = int(input())
s = input()
for i in range(26):
	s = function(s, chr(122 - i))
print(n - len(s))


n = int(input())
s = input()
u = ord('a')
for i in range(n):
	a = 0
	m = 0
	for j in range(len(s)):
		if j == 0:
			if j + 1 < len(s) and ord(s[j]) == ord(s[j + 1]) + 1:
				if ord(s[j]) > m:
					m = ord(s[j])
					a = j
		elif j == len(s) - 1:
			if j - 1 >= 0 and ord(s[j]) == ord(s[j - 1]) + 1:
				if ord(s[j]) > m:
					m = ord(s[j])
					a = j
		elif j + 1 < len(s) and ord(s[j]) == ord(s[j + 1]) + 1 or (j - 1 >= 0 and ord(s[j]) == ord(s[j - 1]) + 1):
			if ord(s[j]) > m:
				m = ord(s[j])
				a = j
	if m == 0:
		print(n - len(s))
		exit()
	else:
		s = s[0:a] + s[a + 1:len(s)]


import sys
input = sys.stdin.readline
n = int(input())
a = input()
A = [100]
for i in a:
	A.append(ord(i) - 97)
A.append(100)
B = [i for i in range(26, -1, -1)]
for i in B:
	j = 1
	while j < len(A) - 1:
		if A[j] == i:
			if A[j] == A[j - 1] + 1 or A[j] == A[j + 1] + 1:
				A.pop(j)
				j = 1
			else:
				j = j + 1
		else:
			j = j + 1
print(n - len(A) + 3)


from collections import defaultdict
n = int(input())
s = input()
d = {}
d = defaultdict(lambda : 0, d)
for i in s:
	d[i] = 1
arr = []
for i in d.keys():
	arr.append(i)
arr = sorted(arr, reverse=True)
s = ' ' + s + ' '
count = 0
for j in arr:
	i = 0
	while i <= n - count and len(s) > 3:
		if s[i] == j:
			if ord(s[i]) - ord(s[i - 1]) == 1 or ord(s[i]) - ord(s[i + 1]) == 1:
				s = s[:i] + s[i + 1:]
				count += 1
				i -= 2
		i += 1
print(count)


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
import string

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

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

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

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

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

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
n = ii()
a = string.ascii_lowercase
s = [x for x in input()]
t = len(s)
c = 25
while c > 0:
	j = 0
	while j < len(s):
		if s[j] == a[c]:
			if j > 0 and s[j - 1] == a[c - 1] or (j < len(s) - 1 and s[j + 1] == a[c - 1]):
				s.pop(j)
				(c, j) = (25, 0)
				continue
		j += 1
	c -= 1
print(t - len(s))


import sys

def maxremovable(s):
	mx = -1
	for i in range(len(s)):
		if i - 1 >= 0 and ord(s[i]) - ord(s[i - 1]) == 1:
			if mx == -1:
				mx = i
			elif s[mx] < s[i]:
				mx = i
		if i + 1 < len(s) and ord(s[i]) - ord(s[i + 1]) == 1:
			if mx == -1:
				mx = i
			elif s[mx] < s[i]:
				mx = i
	return mx

def ip():
	n = sys.stdin.readline()
	s = sys.stdin.readline()
	ct = 0
	while True:
		mx = maxremovable(s)
		if mx == -1:
			break
		ct += 1
		s = s[:mx] + s[mx + 1:]
	print(ct)
ip()


from sys import stdin
inf = stdin
n = int(inf.readline())
s = inf.readline()
s = s[:n]
maxyet = 0
while maxyet != -1 and len(s) > 1:
	maxyet = -1
	nn = len(s)
	for i in range(nn):
		if i > 0 and ord(s[i]) - 1 == ord(s[i - 1]) or (i < nn - 1 and ord(s[i + 1]) + 1 == ord(s[i])):
			if maxyet != -1:
				if s[i] > s[maxyet]:
					maxyet = i
			else:
				maxyet = i
	if maxyet != -1:
		s = s[:maxyet] + s[maxyet + 1:]
print(n - len(s))


n = int(input())
s = list(input())
s = [ord(x) - ord('a') for x in s]
l = [[] for i in range(26)]
ans = 0
for i in range(25, -1, -1):
	k = 0
	while k < len(s):
		if s[k] == i:
			if k - 1 >= 0 and s[k] - 1 == s[k - 1]:
				s.pop(k)
				k -= 1
				ans += 1
			if k + 1 < len(s) and s[k] - 1 == s[k + 1]:
				s.pop(k)
				k = -1
				ans += 1
		k += 1
print(ans)


from sys import exit

def i():
	return input()

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

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

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

def print_array(a):
	print(' '.join(map(str, a)))
n = ii()
s = input()
alph = ['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']
alph = alph[::-1]
count = 0
for c in alph:
	for j in range(n):
		for i in range(len(s)):
			if s[i] == c:
				if i > 0 and ord(s[i - 1]) == ord(s[i]) - 1 or (i < len(s) - 1 and ord(s[i + 1]) == ord(s[i]) - 1):
					s = s[:i] + s[i + 1:]
					count += 1
					break
print(count)


n = int(input())
word = input()
s = 'abcdefghijklmnopqrstuvwxyz'
s = s[-1::-1]
for i in range(25):
	cur = s[i]
	prev = s[i + 1]
	while cur in word and prev in word:
		ans = ''
		for j in range(len(word)):
			if word[j] == cur:
				f = 0
				if j - 1 >= 0:
					if word[j - 1] == prev:
						f = 1
				if j + 1 < len(word):
					if word[j + 1] == prev:
						f = 1
				if f == 1:
					pass
				else:
					ans += word[j]
			else:
				ans += word[j]
		if word == ans:
			break
		word = ans[:]
print(n - len(word))


import re
n = int(input())
s = input()
y = 'z'
while 'a' < y:
	x = y + '*'
	y = chr(ord(y) - 1)
	s = re.sub(x + y + x, y, s)
print(n - len(s))


n = int(input())
s = list(input())
letters = [0] * 26
for c in s:
	letters[ord(c) - ord('a')] += 1
it = 25

def can_be_deleted(s, i):
	if i - 1 >= 0 and i + 1 < len(s):
		return ord(s[i - 1]) + 1 == ord(s[i]) or ord(s[i + 1]) + 1 == ord(s[i])
	if i == 0:
		return ord(s[i + 1]) + 1 == ord(s[i])
	if i == len(s) - 1:
		return ord(s[i - 1]) + 1 == ord(s[i])
score = 0
while it >= 0:
	if letters[it] == 0:
		it -= 1
		continue
	i = 0
	deleted = False
	while i < len(s) and len(s) > 1:
		if s[i] == chr(ord('a') + it) and can_be_deleted(s, i):
			del s[i]
			score += 1
			deleted = True
			break
		i += 1
	if not deleted:
		it -= 1
print(score)


n = int(input())
s = input()

def f(s, c, cc):
	m = len(s)
	if m == 1:
		return s
	l = [1] * m
	for i in range(m - 1):
		if s[i] == cc and s[i + 1] == c:
			l[i + 1] = 0
		if s[i] == c and s[i + 1] == c:
			l[i + 1] = l[i]
	for i in range(m - 1, 0, -1):
		if s[i] == cc and s[i - 1] == c:
			l[i - 1] = 0
		if s[i] == c and s[i - 1] == c:
			l[i - 1] = l[i]
	ret = ''
	for i in range(m):
		if l[i] == 1:
			ret += s[i]
	return ret
for x in range(122, 97, -1):
	s = f(s, chr(x), chr(x - 1))
print(n - len(s))


n = int(input())
s = list(input())
for i in range(n):
	s[i] = ord(s[i]) - 97
ch = [i for i in range(26, -1, -1)]
s = [-100] + s + [-100]
for i in ch:
	j = 1
	while j < len(s) - 1:
		if s[j] == i:
			if s[j] == s[j - 1] + 1 or s[j] == s[j + 1] + 1:
				s.pop(j)
				j = 1
			else:
				j += 1
		else:
			j += 1
print(n + 2 - len(s))


import sys
import math
import bisect

def solve(A):
	n = len(A)
	for i in range(25, -1, -1):
		to_loop = True
		while to_loop:
			to_loop = False
			for j in range(len(A)):
				if A[j] == i and j - 1 >= 0 and (A[j - 1] == i - 1):
					A = A[0:j] + A[j + 1:]
					to_loop = True
					break
				elif A[j] == i and j + 1 < len(A) and (A[j + 1] == i - 1):
					A = A[0:j] + A[j + 1:]
					to_loop = True
					break
	return n - len(A)

def main():
	n = int(input())
	A = list(input())
	for i in range(n):
		A[i] = ord(A[i]) - ord('a')
	ans = solve(A)
	print(ans)

def __starting_point():
	main()
__starting_point()


import re
n = int(input())
s = input()
y = 'z'
for _ in y * 25:
	x = y + '*'
	y = chr(ord(y) - 1)
	s = re.sub(x + y + x, y, s)
print(n - len(s))


n = int(input())
ar = [ord(x) - 97 for x in input()]
ans = 0
flag = True
while flag:
	temp = -1
	ind = -1
	for k in range(1, len(ar) - 1):
		if (ar[k] == ar[k - 1] + 1 or ar[k] == ar[k + 1] + 1) and ar[k] > temp:
			ind = k
			temp = ar[k]
	if len(ar) > 1 and ar[0] == ar[1] + 1 and (ar[0] > temp):
		ind = 0
		temp = ar[0]
	if len(ar) > 1 and ar[-1] == ar[-2] + 1 and (ar[-1] > temp):
		ind = len(ar) - 1
		temp = ar[-1]
	if temp != -1:
		ar = ar[:ind] + ar[ind + 1:]
		ans += 1
	else:
		flag = False
print(ans)


def filtered(s, filt):
	buf = ''
	for tp in zip(s, filt):
		if not tp[1]:
			buf += tp[0]
	return buf
n = int(input())
s = input()
for c in range(25, 0, -1):
	deleted = [False] * len(s)
	for i in range(len(s)):
		j = i + 1
		while j < len(s) and c + ord('a') == ord(s[j]) and (ord(s[j]) - ord(s[i]) == 1):
			deleted[j] = True
			j += 1
		j = i - 1
		while j >= 0 and c + ord('a') == ord(s[j]) and (ord(s[j]) - ord(s[i]) == 1):
			deleted[j] = True
			j -= 1
	s = filtered(s, deleted)
print(n - len(s))


le = int(input())
ar = list('0' + input() + '0')
al = list('abcdefghijklmnopqrstuvwxyz')
dic = {'0': -5}
for i in range(1, 27):
	dic[al[i - 1]] = i
count = 0
for i in range(le):
	li = 0
	for i in range(1, len(ar) - 1):
		if dic[ar[i]] - dic[ar[i + 1]] == 1 or dic[ar[i]] - dic[ar[i - 1]] == 1:
			if dic[ar[li]] < dic[ar[i]]:
				li = i
	if li != 0:
		del ar[li]
		count += 1
print(count)


n = int(input())
s = input().strip()
l = [ord(x) - ord('a') for x in s]
cnt = 0
while True:
	mi = None
	if n - cnt == 1:
		break
	if l[0] - 1 == l[1]:
		mi = 0
	for i in range(n - 1 - cnt):
		if l[i - 1] + 1 == l[i] or l[i + 1] + 1 == l[i]:
			if mi == None or l[mi] < l[i]:
				mi = i
	if l[n - 2 - cnt] + 1 == l[n - 1 - cnt]:
		mi = n - 1 - cnt
	if mi == None:
		break
	l.pop(mi)
	cnt += 1
print(cnt)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

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

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

def ws(s):
	sys.stdout.write(s + '\n')

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

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		n = ri()
		s = rs()
		while True:
			m = 0
			for i in range(len(s)):
				if i >= 1 and ord(s[i - 1]) + 1 == ord(s[i]):
					if ord(s[i]) > m:
						ind = i
					m = max(m, ord(s[i]))
				if i < len(s) - 1 and ord(s[i + 1]) + 1 == ord(s[i]):
					if ord(s[i]) > m:
						ind = i
					m = max(m, ord(s[i]))
			if m > 0:
				s = s[:ind] + s[ind + 1:]
			else:
				break
		print(n - len(s))
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


from sys import stdin, stdout
import string
n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
lett = string.ascii_lowercase
lett = list(reversed(lett))
for l in range(25):
	chg = True
	while chg and len(s) > 1:
		chg = False
		i = 0
		while len(s) > 1 and i < len(s):
			if s[i] == lett[l]:
				if i == 0 and s[1] == lett[l + 1]:
					chg = True
					s = s[1:]
				elif i == 0:
					i += 1
				elif i == len(s) - 1 and s[i - 1] == lett[l + 1]:
					chg = True
					s = s[:i]
				elif i == len(s) - 1:
					i += 1
				elif s[i - 1] == lett[l + 1] or s[i + 1] == lett[l + 1]:
					s = s[:i] + s[i + 1:]
					chg = True
				else:
					i += 1
			else:
				i += 1
print(n - len(s))


def solve(n, s):
	alphabet = 'zyxwvutsrqponmlkjihgfedcba'
	for (i, c) in enumerate(alphabet):
		if c == 'a':
			continue
		nxt = alphabet[i + 1]
		cnt = s.count(c)
		for _ in range(cnt):
			for (j, v) in enumerate(s):
				if c != v or len(s) == 1:
					continue
				if j == 0:
					if s[j + 1] == nxt:
						s.pop(j)
				elif j == len(s) - 1:
					if s[j - 1] == nxt:
						s.pop(j)
				elif s[j + 1] == nxt or s[j - 1] == nxt:
					s.pop(j)
	print(n - len(s))

def main():
	n = int(input())
	s = input()
	solve(n, list(s))
main()


n = int(input())
L = list(input())
ans = 0
for i in range(25):
	target = chr(ord('z') - i)
	rm = chr(ord('z') - i - 1)
	update = True
	while update:
		update = False
		j = 0
		while j < len(L):
			if L[j] == target:
				v = []
				if j > 0:
					v.append(L[j - 1])
				if j + 1 < len(L):
					v.append(L[j + 1])
				if rm in v:
					L = L[:j] + L[j + 1:]
					j -= 1
					ans += 1
					update = True
			j += 1
print(ans)


n = int(input())
s = str(input())
al = 'abcdefghijklmnopqrstuvwxyz'
ans = 0

def p(a, j):
	global s, n
	if s[0] == a and s[1] == al[j - 1]:
		s = s[1:]
		n -= 1
		return True
	if s[n - 1] == a and s[n - 2] == al[j - 1]:
		s = s[:n - 1]
		n -= 1
		return True
	for i in range(1, n - 1):
		if s[i] == a:
			if s[i + 1] == al[j - 1]:
				s = s[:i] + s[i + 1:]
				n -= 1
				return True
			if s[i - 1] == al[j - 1]:
				s = s[:i] + s[i + 1:]
				n -= 1
				return True
	return False
j = 25
while j > 0 and n > 1:
	while p(al[j], j):
		ans += 1
	j = j - 1
if n > 1 and (s in al or s[::-1] in al):
	ans += 1
print(ans)


leng = int(input())
word = list(input())
best = 0
count = 0
while best != -1:
	best = -1
	best_i = -1
	for i in range(len(word)):
		c = word[i]
		if ord(c) > best:
			for x in [i - 1, i + 1]:
				if 0 <= x < len(word) and ord(word[x]) == ord(c) - 1:
					best = ord(c)
					best_i = i
	if best_i != -1:
		word.pop(best_i)
		count += 1
print(count)


n = int(input())
s = list(input())
for i in range(n):
	l = []
	for j in range(len(s)):
		if j > 0 and ord(s[j]) == ord(s[j - 1]) + 1:
			l.append([s[j], j])
		if j < len(s) - 1 and ord(s[j]) == ord(s[j + 1]) + 1:
			l.append([s[j], j])
	if len(l) == 0:
		break
	l.sort()
	s1 = ''
	for i in range(len(s)):
		if i == l[-1][1]:
			continue
		s1 += s[i]
	s = s1[:]
a = ''
for i in s:
	if ord(i) == 13:
		continue
	a += i
print(n - len(a))


def func(a):
	if len(a) == 1:
		return a
	ral = 0
	a = '(' + a + ')'
	flag = True
	for i in range(1, len(a) - 1):
		p = i
		if chr(ord(a[p]) - 1) == a[p + 1] or chr(ord(a[p]) - 1) == a[p - 1]:
			if ral <= ord(a[p]):
				ral = ord(a[p])
				k = p
				flag = False
	a = a[1:len(a) - 1]
	if flag == False:
		k = k - 1
		a = func(a[0:k] + a[k + 1:])
	return a
n = int(input())
a = input()
a = func(a)
print(n - len(a))


sl = int(input())
s = input()
v = [[s[x], 0] for x in range(sl)]
for i in range(sl):
	if i - 1 >= 0 and ord(v[i - 1][0]) == ord(v[i][0]) - 1:
		v[i][1] += 1
	if i + 1 < sl and ord(v[i + 1][0]) == ord(v[i][0]) - 1:
		v[i][1] += 1
ans = 0

def findmax(va):
	ind = -1
	ans = ['a', 0]
	for i in range(len(v)):
		if va[i][1] == 0:
			continue
		elif ans < va[i]:
			ind = i
			ans = va[i]
	return ind
mi = findmax(v)
while mi != -1:
	if mi - 1 >= 0 and ord(v[mi - 1][0]) - 1 == ord(v[mi][0]):
		v[mi - 1][1] -= 1
	if mi + 1 < len(v) and ord(v[mi + 1][0]) - 1 == ord(v[mi][0]):
		v[mi + 1][1] -= 1
	pv = v.pop(mi)
	if mi < len(v) and mi - 1 >= 0 and (ord(v[mi][0]) - 1 == ord(v[mi - 1][0])):
		v[mi][1] += 1
	if mi < len(v) and mi - 1 >= 0 and (ord(v[mi][0]) + 1 == ord(v[mi - 1][0])):
		v[mi - 1][1] += 1
	mi = findmax(v)
	ans += 1
print(ans)


def solve(N, S):
	for c in sorted(set(S), key=ord, reverse=True):
		temp = []
		val = ord(c)
		for x in S:
			if ord(x) == val:
				if temp and ord(temp[-1]) == val - 1:
					continue
			if ord(x) == val - 1:
				while temp and ord(temp[-1]) == val:
					temp.pop()
			temp.append(x)
		S = temp
	return N - len(S)
(N,) = map(int, input().split())
S = list(input())
ans = solve(N, S)
print(ans)


n = int(input())
s = input()
now = ord('z')
st = ord('a')
tong = []
for i in range(144):
	tong.append(0)
for c in s:
	tong[ord(c)] += 1
ans = 0
maxs = max(s)
now = 0
while ord(maxs) > ord('a'):
	pos = s.find(maxs, now)
	if pos != -1:
		if pos - 1 >= 0 and ord(s[pos - 1]) == ord(maxs) - 1 or (pos + 1 < len(s) and ord(s[pos + 1]) == ord(maxs) - 1):
			s = s[0:pos] + s[pos + 1:len(s)]
			now = 0
			ans += 1
		else:
			now = pos + 1
	else:
		maxs = chr(ord(maxs) - 1)
		now = 0
print(ans)


from sys import stdin, stdout
n = int(stdin.readline().strip())
s = stdin.readline().strip()

def removable(i, x):
	li = max(0, i - 1)
	ri = min(x - 1, i + 1)
	if ord(s[i]) == ord(s[li]) + 1 or ord(s[i]) == ord(s[ri]) + 1:
		return True
	return False
ansarr = []
for i in s:
	ansarr.append(i)
flag = True
while flag:
	flag = False
	pos = []
	for i in range(len(s)):
		if removable(i, len(s)):
			pos.append((s[i], i))
	pos = sorted(pos, key=lambda ele: ele[0])
	if len(pos) > 0:
		s = s[:pos[-1][1]] + s[pos[-1][1] + 1:]
		flag = True
stdout.write(str(n - len(s)) + '\n')


n = int(input())
S = list(input())
res = 0
for i in range(26):
	look_for = ord('z') - i
	cont = True
	while cont:
		cont = False
		j = 0
		while j < n:
			if look_for == ord(S[j]):
				l = j - 1
				r = j + 1
				if l in range(n) and look_for - 1 == ord(S[l]) or (r in range(n) and look_for - 1 == ord(S[r])):
					del S[j]
					j -= 1
					n -= 1
					res += 1
					cont = True
			j += 1
print(res)


n = input()
s = input()
s = [char for char in s]
alphabet = ['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']
inst = []
go = True
no = []
for a in range(25, 0, -1):
	go = True
	while go:
		inst = []
		for b in range(len(s)):
			if s[b] == alphabet[a]:
				inst.append(b)
		go = False
		no = []
		for i in inst:
			if i != 0 and s[i - 1] == alphabet[a - 1]:
				no.append(i)
				go = True
			elif i != len(s) - 1 and s[i + 1] == alphabet[a - 1]:
				no.append(i)
				go = True
		for i in range(len(no) - 1, -1, -1):
			s.pop(no[i])
print(str(int(n) - len(s)))


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

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

def si():
	return input()

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

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
from math import ceil, floor, log, sqrt, factorial
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

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

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

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

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

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def s(a):
	while a >= 10:
		x = 0
		while a:
			x += a % 10
			a //= 10
		a = x
	return a

def main():
	n = ii()
	s = list(si())
	x = n
	if n == 1:
		print(0)
		exit()
	for i in range(25, 0, -1):
		if len(s) == 1:
			break
		while True:
			fff = 0
			j = 0
			while j < n:
				if len(s) == 1:
					break
				if s[j] == abc[i]:
					if j == 0:
						if abd[s[j + 1]] == i - 1:
							del s[j]
							j -= 1
							n -= 1
							fff = 1
					elif j == n - 1:
						if abd[s[j - 1]] == i - 1:
							del s[j]
							j -= 1
							n -= 1
							fff = 1
					elif abd[s[j + 1]] == i - 1:
						del s[j]
						n -= 1
						j -= 1
						fff = 1
					elif abd[s[j - 1]] == i - 1:
						del s[j]
						j -= 1
						n -= 1
						fff = 1
				j += 1
			if fff == 0:
				break
	print(x - n)
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')
main()


n = int(input())
b = [i for i in map(ord, input())]
for i in range(max(b), min(b), -1):
	while True and len(b) > 1:
		idx = []
		if b[0] == b[1] + 1 and b[0] == i:
			idx.append(0)
		for j in range(1, len(b) - 1):
			if b[j] == i and (b[j] == b[j - 1] + 1 or b[j] == b[j + 1] + 1):
				idx.append(j)
		if b[-1] == b[-2] + 1 and b[-1] == i:
			idx.append(len(b) - 1)
		if len(idx) == 0:
			break
		for j in range(len(idx)):
			del b[idx[j] - j]
print(n - len(b))


import sys
n = int(input())
s = str(input())
flag = True
while len(s) > 1:
	(maxChar, pos) = (chr(ord('a') - 1), -1)
	for i in range(len(s)):
		if maxChar < s[i]:
			if i == 0:
				if ord(s[i]) == ord(s[i + 1]) + 1:
					maxChar = s[i]
					pos = i
			elif i == len(s) - 1:
				if ord(s[i]) == ord(s[i - 1]) + 1:
					maxChar = s[i]
					pos = i
			elif ord(s[i]) == ord(s[i + 1]) + 1 or ord(s[i]) == ord(s[i - 1]) + 1:
				maxChar = s[i]
				pos = i
	if pos != -1:
		s = s[:pos] + s[pos + 1:]
	else:
		break
print(n - len(s))


import sys
from array import array
from typing import List, Tuple, TypeVar, Generic, Sequence, Union

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def main():
	from itertools import groupby
	n = int(input())
	a = [(ord(k), len(list(v))) for (k, v) in groupby('*' + input().rstrip() + '*')]
	ans = 0
	while True:
		(j, cc) = (-1, -1)
		for i in range(1, len(a) - 1):
			if (a[i][0] - 1 == a[i - 1][0] or a[i][0] - 1 == a[i + 1][0]) and a[i][0] > cc:
				cc = a[i][0]
				j = i
		if j == -1:
			break
		ans += a.pop(j)[1]
	print(ans)
main()


import sys
input = sys.stdin.readline
import heapq
import copy
import math
import decimal

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def insr2():
	s = input()
	return s[:len(s) - 1]

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

def pr_list(a):
	print(*a, sep=' ')

def main():
	tests = 1
	mod = 1000000007
	limit = 10 ** 18
	ans = 0
	stack = []
	hashm = {}
	arr = []
	heapq.heapify(arr)
	for test in range(tests):
		n = inp()
		s = insr()
		for i in range(len(s)):
			s[i] = ord(s[i])
		hashm = {}

		def helper(s, target):
			while True and len(s) > 1:
				flag = 0
				if s[0] == target and s[1] == target - 1:
					s = s[1:len(s)]
					flag = 1
					continue
				if s[-1] == target and s[-2] == target - 1:
					s = s[0:len(s) - 1]
					flag = 1
					continue
				for i in range(1, len(s) - 1):
					if s[i] == target and (s[i - 1] == target - 1 or s[i + 1] == target - 1):
						flag = 1
						s = s[0:i] + s[i + 1:len(s)]
						break
				if flag == 0:
					break
			return s
		for i in range(26):
			s = helper(s, ord('z') - i)
		print(n - len(s))
main()


from sys import stdin
from collections import defaultdict

def iinput():
	return int(stdin.readline())

def sinput():
	return input()

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

def linput():
	return list(map(int, stdin.readline().split()))
n = iinput()
s = sinput()
l = list(set(s))
l.sort(reverse=True)
if l[-1] == 'a':
	l.pop()
s = list(s)
ans = 0
for c in l:
	i = 0
	while i < len(s):
		try:
			if i > 0 and s[i] == c and (s[i - 1] == chr(ord(c) - 1)) or (i < len(s) - 1 and s[i] == c and (s[i + 1] == chr(ord(c) - 1))):
				ans += 1
				s.pop(i)
				i -= 1
			else:
				i += 1
		except:
			i += 1
print(ans)


n = int(input())
l = list(input())
a = [0] * 26
b = [0] * 26
for i in range(n):
	a[ord(l[i]) - 97] = 1
	b[ord(l[i]) - 97] += 1
ans = 0
for i in range(25, -1, -1):
	if a[i] == 1:
		while True:
			j = 0
			while j < len(l):
				if l[j] == chr(i + 97):
					if j > 0 and l[j - 1] == chr(i + 96):
						l.pop(j)
						ans += 1
						b[i] -= 1
						j -= 1
					elif j < len(l) - 1 and l[j + 1] == chr(i + 96):
						l.pop(j)
						ans += 1
						b[i] -= 1
						j -= 1
				j += 1
			j = len(l) - 1
			while j >= 0:
				if l[j] == chr(i + 97):
					if j > 0 and l[j - 1] == chr(i + 96):
						l.pop(j)
						ans += 1
						b[i] -= 1
					elif j < len(l) - 1 and l[j + 1] == chr(i + 96):
						l.pop(j)
						ans += 1
						b[i] -= 1
				j -= 1
			break
print(ans)


def main():
	for _ in range(1):
		n = int(input())
		s = tuple((ord(c) - 97 for c in input()))
		ans = 0
		while True:
			b = True
			mx_ = -1
			mx_i = -1
			for i in range(n):
				if i > 0 and s[i] - s[i - 1] == 1:
					b = False
					if s[i] > mx_:
						mx_i = i
						mx_ = s[i]
				if i < n - 1 and s[i] - s[i + 1] == 1:
					b = False
					if s[i] > mx_:
						mx_i = i
						mx_ = s[i]
			if b:
				break
			ans += 1
			n -= 1
			s = s[:mx_i] + s[mx_i + 1:]
		print(ans)
main()


import copy
n = int(input())
s = input()
ar = list(s)
count = 0
for i in range(122, 96, -1):
	br = []
	l = len(ar)
	for j in range(l):
		if l == 1:
			break
		if ord(ar[j]) == i:
			if j == 0:
				if ord(ar[j + 1]) == i - 1:
					count += 1
					ar[j] = ar[j + 1]
				else:
					br.append(ar[j])
			elif j == l - 1:
				if ord(ar[j - 1]) == i - 1:
					ar[j] = ar[j - 1]
					count += 1
				else:
					br.append(ar[j])
			elif ord(ar[j + 1]) == i - 1:
				ar[j] = ar[j + 1]
				count += 1
			elif ord(ar[j - 1]) == i - 1:
				ar[j] = ar[j - 1]
				count += 1
			else:
				br.append(ar[j])
		else:
			br.append(ar[j])
	ar = copy.deepcopy(br)
	br = []
	l = len(ar)
	for j in range(l - 1, -1, -1):
		if l == 1:
			break
		if ord(ar[j]) == i:
			if j == 0:
				if ord(ar[j + 1]) == i - 1:
					count += 1
					ar[j] = ar[j + 1]
				else:
					br.append(ar[j])
			elif j == l - 1:
				if ord(ar[j - 1]) == i - 1:
					ar[j] = ar[j - 1]
					count += 1
				else:
					br.append(ar[j])
			elif ord(ar[j + 1]) == i - 1:
				ar[j] = ar[j + 1]
				count += 1
			elif ord(ar[j - 1]) == i - 1:
				ar[j] = ar[j - 1]
				count += 1
			else:
				br.append(ar[j])
		else:
			br.append(ar[j])
	ar = copy.deepcopy(br)
	br = []
print(count)


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	s = '&' + input()
	s += '&'
	ans = 0
	for i in range(97 + 26 - 1, 96, -1):
		j = 0
		while j < len(s) - 1:
			if ord(s[j]) == i:
				if ord(s[j - 1]) + 1 == ord(s[j]) or ord(s[j + 1]) + 1 == ord(s[j]):
					s = s[:j] + s[j + 1:]
					ans += 1
				else:
					j += 1
			else:
				j += 1
		j = len(s) - 1
		while j > 0:
			if ord(s[j]) == i:
				if ord(s[j - 1]) + 1 == ord(s[j]) or ord(s[j + 1]) + 1 == ord(s[j]):
					s = s[:j] + s[j + 1:]
					ans += 1
				else:
					j -= 1
			else:
				j -= 1
	print(ans)
main()


import sys
n = int(input())
s = input()
temp = []
for i in range(n):
	temp.append(s[i])
s = temp
v = set()
for i in s:
	v.add(i)
ans = 0
for i in range(25, -1, -1):
	curr = chr(i + ord('a'))
	temp = set()
	if curr in v:
		l = len(s)
		for k in range(l):
			if s[k] == curr:
				if k - 1 >= 0:
					if ord(s[k - 1]) + 1 == ord(curr):
						ans += 1
						temp.add(k)
						s[k] = s[k - 1]
		for k in range(l - 1, -1, -1):
			if s[k] == curr:
				if k + 1 < l:
					if ord(s[k + 1]) + 1 == ord(curr):
						ans += 1
						temp.add(k)
						s[k] = s[k + 1]
		q = []
		for k in range(l):
			if k not in temp:
				q.append(s[k])
		s = q
print(ans)


n = int(input())
s = input()
a = [x for x in s]
for j in range(25, 0, -1):
	for k in range(n):
		for i in range(len(a)):
			if a[i] == chr(97 + j) and (i > 0 and a[i - 1] == chr(97 + j - 1) or (i < len(a) - 1 and a[i + 1] == chr(97 + j - 1))):
				a.pop(i)
				break
print(n - len(a))


n = int(input())
s = input()
z = list(range(0, 26))[::-1]
ords = [ord(i) - ord('a') for i in s]
for i in z:
	pos = len(ords) - 1
	while pos >= 0:
		if ords[pos] == i:
			if pos - 1 >= 0 and ords[pos - 1] == i - 1 or (pos + 1 < len(ords) and ords[pos + 1] == i - 1):
				del ords[pos]
				if len(ords) == pos:
					pos -= 1
			else:
				pos -= 1
		else:
			pos -= 1
print(n - len(ords))


n = int(input())
s = input()
t = [x for x in s]
for j in range(25, 0, -1):
	for k in range(n):
		for c in range(len(t)):
			if t[c] == chr(j + 97) and (c > 0 and t[c - 1] == chr(j - 1 + 97) or (c < len(t) - 1 and t[c + 1] == chr(j - 1 + 97))):
				t.pop(c)
				break
print(n - len(t))


l = int(input())
s = input()
ans = 0
for i in range(l):
	pos = ('a', -1)
	n = len(s)
	for j in range(n):
		if j > 0:
			if ord(s[j - 1]) == ord(s[j]) - 1:
				pos = max(pos, (s[j], j))
		if j < n - 1:
			if ord(s[j + 1]) == ord(s[j]) - 1:
				pos = max(pos, (s[j], j))
	if pos[1] != -1:
		s = s[:pos[1]] + s[pos[1] + 1:]
		ans += 1
print(ans)


l = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
s = list(input())
for i in range(25, 0, -1):
	remove_this = l[i]
	j = 0
	while j < len(s):
		f = 0
		if s[j] == remove_this:
			if j - 1 > -1:
				if s[j - 1] == l[i - 1]:
					s.pop(j)
					j = 0
					f = 1
			if j + 1 < len(s) and f == 0:
				if s[j + 1] == l[i - 1]:
					s.pop(j)
					j = 0
					f = 1
		if f == 0:
			j += 1
print(n - len(s))


from math import *

def binarySearch(arr, x, i):
	l = i
	r = len(arr) - 1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def js(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] <= x:
			ans = m
			l = m + 1
		else:
			r = m - 1
	return ans

def jg(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= x:
			ans = m
			r = m - 1
		else:
			l = m + 1
	return ans
n = int(input())
s = list(input())
a = 'zyxwvutsrqponmlkjihgfedcb'
count = 0
for i in range(25):
	for j in range(n):
		if s[j] == a[i]:
			x = j - 1
			y = j + 1
			while x >= 0:
				if s[x] == -1 or s[x] == a[i]:
					x -= 1
				elif s[x] == chr(ord(s[j]) - 1):
					break
				else:
					break
			while y < n:
				if s[y] == -1 or s[y] == a[i]:
					y += 1
				elif s[y] == chr(ord(s[j]) - 1):
					break
				else:
					break
			if x >= 0 and s[x] != -1 and (s[x] == chr(ord(s[j]) - 1)) or (y < n and s[y] != -1 and (s[y] == chr(ord(s[j]) - 1))):
				count += 1
				s[j] = -1
print(count)


from collections import Counter, OrderedDict
from itertools import permutations as perm
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().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()]
mod = int(1000000000.0) + 7
inf = float('inf')
(n,) = gil()
s = gcl()
while s:
	rem = None
	for i in range(len(s)):
		if i and ord(s[i - 1]) + 1 == ord(s[i]):
			if rem is None:
				rem = i
			elif s[rem] < s[i]:
				rem = i
		if i + 1 < len(s) and ord(s[i + 1]) + 1 == ord(s[i]):
			if rem is None:
				rem = i
			elif s[rem] < s[i]:
				rem = i
	if rem is None:
		break
	else:
		s.pop(rem)
print(n - len(s))


def charToInt(c):
	return ord(c) - ord('a')
N = int(input())
s = input()
arr = [charToInt(c) for c in s]
didRemove = False
j = 25
while True:
	didRemove = False
	n = len(arr)
	for i in range(n - 1, -1, -1):
		if arr[i] == j and (i - 1 >= 0 and arr[i - 1] + 1 == arr[i] or (i + 1 < n and arr[i + 1] + 1 == arr[i])):
			arr.pop(i)
			didRemove = True
			break
	if didRemove:
		j = 25
	else:
		j -= 1
	if j == 0:
		break
print(N - n)


ans = 0

def check1(seq, i):
	if i == 0 or i == len(seq) - 1:
		return False
	if seq[i] - seq[i - 1] == 1 and seq[i] - seq[i + 1] == 2:
		return True
	if seq[i] - seq[i + 1] == 1 and seq[i] - seq[i - 1] == 2:
		return True
	if seq[i] - seq[i - 1] == 1 and seq[i] == seq[i + 1]:
		return True
	if seq[i] - seq[i + 1] == 1 and seq[i] == seq[i - 1]:
		return True
	return False

def check2(seq, i):
	if i == 0 or i == len(seq) - 1:
		return True
	if seq[i] - seq[i - 1] == 1 and seq[i + 1] - seq[i] >= 2:
		return True
	if seq[i] - seq[i + 1] == 1 and seq[i - 1] - seq[i] >= 2:
		return True
	if seq[i] - seq[i - 1] == 1 and seq[i] - seq[i + 1] >= 3:
		return True
	if seq[i] - seq[i + 1] == 1 and seq[i] - seq[i - 1] >= 3:
		return True
	if seq[i] - seq[i - 1] == 1 and seq[i] - seq[i + 1] == 1:
		return True
	if seq[i] - seq[i + 1] == 1 and seq[i] - seq[i - 1] == 1:
		return True
	return False

def check3(seq, i):
	if i == 0 or i == len(seq) - 1:
		return False
	if seq[i] - seq[i - 1] == 1 and seq[i + 1] - seq[i] == 1:
		return True
	if seq[i] - seq[i + 1] == 1 and seq[i - 1] - seq[i] == 1:
		return True
	return False

def seq_to_str(seq):
	return ''.join([chr(s + ord('a')) for s in seq])

def make_move(seq):
	global ans
	candidates = []
	if len(seq) > 1:
		if seq[0] - seq[1] == 1:
			candidates.append(0)
		for i in range(1, len(seq) - 1):
			if seq[i] - seq[i + 1] == 1 or seq[i] - seq[i - 1] == 1:
				candidates.append(i)
		if seq[-1] - seq[-2] == 1:
			candidates.append(len(seq) - 1)
		if len(candidates) > 0:
			priopity1 = list()
			priopity2 = list()
			priopity3 = list()
			for cand in candidates:
				if check1(seq, cand):
					priopity1.append(cand)
				elif check2(seq, cand):
					priopity2.append(cand)
				elif check3(seq, cand):
					priopity3.append(cand)
			candidates_sorted = sorted(priopity1, key=lambda cand: seq[cand], reverse=True) + sorted(priopity2, key=lambda cand: seq[cand], reverse=True) + sorted(priopity3, key=lambda cand: seq[cand], reverse=True)
			to_del_index = candidates_sorted[0]
			new_seq = seq[0:to_del_index] + seq[to_del_index + 1:]
			ans += 1
			make_move(new_seq)
_ = int(input())
seq = [ord(s) - ord('a') for s in input()]
make_move(seq)
print(ans)


def previous_char(x, y):
	return ord(x) + 1 == ord(y)
n = int(input().strip())
s = list(input().strip())
ss = list(reversed(sorted([(s[i], i) for i in range(len(s))])))
i = 0
while i < len(ss):
	max_index = ss[i][1]
	if max_index + 1 < len(s) and previous_char(s[max_index + 1], s[max_index]) or (max_index > 0 and previous_char(s[max_index - 1], s[max_index])):
		s = s[:max_index] + s[max_index + 1:]
		ss = list(reversed(sorted([(s[i], i) for i in range(len(s))])))
		i = 0
	else:
		i += 1
print(n - len(s))


n = int(input())
s = input()
alf = 'abcdefghijklmnopqrstuvwxyz'
nums = [[] for i in range(26)]
for i in range(n):
	num = alf.index(s[i])
	nums[num].append(i)
res = 0
e_n_r = {}
e_n_l = {}
que = []
used = [0] * n

def f(k):
	global res, que, e_n_r, e_n_l, used, nums, alf, s, n
	i = alf.index(s[k])
	if used[k] != 0:
		return
	ng = [k - 1, k + 1]
	if e_n_r.get(k) is not None:
		ng[1] = e_n_r[k]
	if e_n_l.get(k) is not None:
		ng[0] = e_n_l[k]
	if ng[0] in nums[i - 1] or ng[1] in nums[i - 1]:
		res += 1
		used[k] = 1
		e_n_r[ng[0]] = ng[1]
		e_n_l[ng[1]] = ng[0]
		if 0 <= ng[0] < n and alf.index(s[ng[0]]) == alf.index(s[k]) and (used[ng[0]] == 0):
			que = [ng[0]] + que
		if 0 <= ng[1] < n and alf.index(s[ng[1]]) == alf.index(s[k]) and (used[ng[1]] == 0):
			que = [ng[1]] + que
for i in range(25, 0, -1):
	for k in nums[i]:
		que.append(k)
while len(que) > 0:
	f(que.pop(0))
print(res)


import sys
input = sys.stdin.readline
n = int(input())
s = [ord(i) for i in input()]
mv = ord('z')
out = 0
for i in range(25):
	cv = mv - i
	pv = mv - i - 1
	j = 0
	ls = len(s)
	while j < ls:
		if s[j] == cv and (j > 0 and s[j - 1] == pv or (j < ls - 1 and s[j + 1] == pv)):
			s = s[:j] + s[j + 1:]
			j = 0
			out += 1
			ls -= 1
		else:
			j += 1
print(out)


import sys
input = sys.stdin.readline
MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input().strip('\n'))
si = lambda : input().strip('\n')
dgl = lambda : list(map(int, input().strip('\n')))
f = lambda : map(int, input().strip('\n').split())
il = lambda : list(map(int, input().strip('\n').split()))
ls = lambda : list(input().strip('\n'))
lsi = lambda : [int(i) for i in ls()]
let = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(1):
	n = ii()
	s = ls()
	for j in reversed(let):
		fg = 1
		while fg:
			fg1 = 0
			if len(s) > 1:
				for i in range(len(s)):
					if s[i] == j:
						if i == 0 and ord(j) - ord(s[i + 1]) == 1:
							s.pop(0)
							fg1 = 1
							break
						elif i == len(s) - 1 and ord(j) - ord(s[i - 1]) == 1:
							s.pop(len(s) - 1)
							fg1 = 1
							break
						elif 0 < i < len(s) - 1 and (ord(j) - ord(s[i + 1]) == 1 or ord(j) - ord(s[i - 1]) == 1):
							s.pop(i)
							fg1 = 1
							break
			fg = fg1
	print(n - len(s))


n = int(input())
x = list(input())
y = len(x)
abc = list('abcdefghijklmnopqrstuvwxyz')
pre = list('0abcdefghijklmnopqrstuvwxy')
for i in range(1, len(abc)):
	s = 0
	while s < len(x):
		if x[s] == abc[-i]:
			if s - 1 >= 0 and x[s - 1] == pre[-i]:
				del x[s]
				s -= 1
			elif s + 1 < len(x) and x[s + 1] == pre[-i]:
				del x[s]
				if s > 0:
					s -= 2
				else:
					s -= 1
		s += 1
answer = y - len(x)
print(answer)


import sys
import math
from bisect import bisect_right as br
from itertools import combinations as cb

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

def str_arr():
	return list(map(str, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
n = int(input())
arr = [ord(i) - 96 for i in input()]
arr.append(-1)
arr.insert(0, -1)
ans = 0
for i in range(26, 0, -1):
	j = 1
	while j < len(arr) - 1:
		if arr[j] == i and (arr[j - 1] == i - 1 or arr[j + 1] == i - 1):
			arr.pop(j)
			ans += 1
			j = 1
			continue
		j += 1
print(ans)


from collections import defaultdict
alpha = 'abcdefghijklmnopqrstuvwxyz'
prev = defaultdict(int)
for i in range(1, 26):
	prev[alpha[i]] = alpha[i - 1]
n = int(input())
s = list(input())
ans = 0
while True:
	if len(s) == 1:
		break
	rem_idx = -1
	for i in range(25, 0, -1):
		for j in range(len(s)):
			if s[j] == alpha[i]:
				if j == 0:
					if s[j + 1] == prev[s[j]]:
						rem_idx = j
						break
				elif j == len(s) - 1:
					if s[j - 1] == prev[s[j]]:
						rem_idx = j
						break
				elif s[j - 1] == prev[s[j]] or s[j + 1] == prev[s[j]]:
					rem_idx = j
					break
		else:
			continue
		break
	if rem_idx == -1:
		break
	ans += 1
	s = [s[i] for i in range(len(s)) if i != rem_idx]
print(ans)


n = int(input())
st = input()
k = 0
while True:
	mx1 = -1
	ar = 96
	for i in range(len(st)):
		if i + 1 < len(st):
			if ord(st[i]) + 1 == ord(st[i + 1]) or ord(st[i]) - 1 == ord(st[i + 1]):
				if ar <= ord(st[i]):
					mx1 = i
					ar = ord(st[i])
		if i - 1 >= 0:
			if ord(st[i]) + 1 == ord(st[i - 1]) or ord(st[i]) - 1 == ord(st[i - 1]):
				if ar <= ord(st[i]):
					mx1 = i
					ar = ord(st[i])
	if mx1 == -1:
		break
	else:
		st = st[:mx1] + st[mx1 + 1:]
		k += 1
print(k)


import sys
import os
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')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	return [[default for j in range(m)] for i in range(n)]

def arr3D(n, m, r, default=0):
	return [[[default for k in range(r)] for j in range(m)] for i in range(n)]

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

class DSU:

	def __init__(self, length):
		self.length = length
		self.parent = [-1] * self.length

	def getParent(self, node, start):
		if node >= self.length:
			return False
		if self.parent[node] < 0:
			if start != node:
				self.parent[start] = node
			return node
		return self.getParent(self.parent[node], start)

	def union(self, node1, node2):
		parent1 = self.getParent(node1, node1)
		parent2 = self.getParent(node2, node2)
		if parent1 == parent2:
			return False
		elif self.parent[parent1] <= self.parent[parent2]:
			self.parent[parent1] += self.parent[parent2]
			self.parent[parent2] = parent1
		else:
			self.parent[parent2] += self.parent[parent1]
			self.parent[parent1] = parent2
		return True

	def getCount(self, node):
		return -self.parent[self.getParent(node, node)]

def solve(n, st):
	if n == 1:
		return 0
	start = n
	curr = ord('z')
	for j in range(ord('z'), ord('a') - 1, -1):
		for k in range(n):
			st1 = ''
			for i in range(n):
				if len(st) == 1:
					st1 += st[0]
				elif i == 0:
					if j != ord('a'):
						if st[i] == chr(j) and st[i + 1] == chr(j - 1):
							continue
					st1 += st[i]
				elif i == n - 1:
					if j != ord('a'):
						if st[i] == chr(j) and st[i - 1] == chr(j - 1):
							continue
					st1 += st[i]
				else:
					if j != ord('a'):
						if st[i] == chr(j) and (st[i - 1] == chr(j - 1) or st[i + 1] == chr(j - 1)):
							continue
					st1 += st[i]
			st = st1
			n = len(st)
	return start - len(st)
n = int(input())
st = input()
print(solve(n, st))


n = int(input())
l = list(input())
ct = []
x = ''
i = 0
while i < n:
	t = l[i]
	x = x + l[i]
	c = 0
	while t == l[i]:
		c = c + 1
		i = i + 1
		if i == n:
			break
	ct.append(c)
l = list(x)
ans = 0
f = 1
while f:
	f = 0
	m = 'a'
	mi = 0
	for i in range(1, len(l)):
		if abs(ord(l[i]) - ord(l[i - 1])) == 1:
			if max(ord(l[i]), ord(l[i - 1])) > ord(m):
				if ord(l[i]) > ord(l[i - 1]):
					m = l[i]
					mi = i
				else:
					m = l[i - 1]
					mi = i - 1
			f = 1
	if f:
		ans = ans + ct[mi]
		l.pop(mi)
		ct.pop(mi)
print(ans)


import re
from functools import reduce

def iter(s, idx):
	chA = chr(ord('a') + idx - 1)
	chB = chr(ord(chA) + 1)
	patL = re.compile(f'{chA}{chB}+')
	patR = re.compile(f'{chB}+{chA}')
	return re.sub(patR, chA, re.sub(patL, chA, s))
origin = int(input())
s = reduce(iter, range(25, 0, -1), input().strip())
print(origin - len(s))


n = int(input())
s = input()
if n == 1:
	print(0)
	exit()
l = []
for i in s:
	l.append(ord(i) - 97)
f = 1
while f:
	o = []
	m = -1
	d = -1
	i = 0
	f = 0
	if len(l) == 1:
		break
	while i < len(l):
		if i == 0:
			if l[i] - 1 == l[i + 1]:
				if l[i] > m:
					f = 1
					m = l[i]
					d = i
			i = i + 1
			continue
		if i == len(l) - 1:
			if l[i] - 1 == l[i - 1]:
				if l[i] > m:
					f = 1
					m = l[i]
					d = i
			i = i + 1
			continue
		if l[i] - 1 == l[i - 1] or l[i] - 1 == l[i + 1]:
			if l[i] > m:
				f = 1
				m = l[i]
				d = i
		i = i + 1
	for i in range(len(l)):
		if i == d:
			continue
		o.append(l[i])
	l = o
print(n - len(l))


n = int(input())
f = input()
d = set()
for i in f:
	d.add(i)
d = sorted(list(d))
x = len(d)
count = 0
x1 = len(f)
i = x - 1
while i >= 0:
	flag = 0
	if count + 1 == x1:
		break
	ut = 0
	rty = x1 - 1 - count
	for j in range(1, rty):
		if f[j - ut] == d[i] and (ord(f[j - ut]) - ord(f[j - 1 - ut]) == 1 or ord(f[j - ut]) - ord(f[j + 1 - ut]) == 1):
			count += 1
			f = f[:j - ut] + f[j + 1 - ut:]
			ut += 1
			flag = 1
	if f[0] == d[i] and ord(f[0]) - ord(f[1]) == 1:
		count += 1
		f = f[1:]
		flag = 1
	if f[-1] == d[i] and ord(f[-1]) - ord(f[-2]) == 1:
		count += 1
		flag = 1
		f = f[:-1]
	i -= 1
	i += flag
print(count)


n = int(input())
s = input()
count = 0
lst = []
for i in s:
	lst.append(ord(i))
for j in range(123, 97, -1):
	for k in range(n):
		for i in range(len(lst) - 1):
			if lst[i] == lst[i + 1] - 1:
				if lst[i + 1] == j:
					lst.pop(i + 1)
					count += 1
					break
			elif lst[i] - 1 == lst[i + 1]:
				if lst[i] == j:
					lst.pop(i)
					count += 1
					break
print(count)


n = int(input())
s = [ord(i) for i in input()]
for mx in range(122, 96, -1):
	i = 0
	while i < len(s):
		flag = 1
		if s[i] == mx:
			if i < len(s) - 1:
				if s[i + 1] == s[i] - 1:
					j = i
					while s[j] == mx:
						del s[j]
						j -= 1
						i -= 1
						if j == -1:
							break
					i += 1
					flag = 0
			if i:
				if s[i - 1] == s[i] - 1 and flag:
					j = i
					while s[j] == mx:
						del s[j]
						if j == len(s):
							break
					flag = 0
		if flag:
			i += 1
print(n - len(s))


import string
import fileinput
alphabet_list = list(string.ascii_lowercase)
counter = 0
inputstring = ''
s = int(input())
inputstring = input()
inputList = list(inputstring)
trueCondition = [False for _ in range(s)]

def returnPrevious(alphabet):
	if alphabet != 'a':
		return alphabet_list[alphabet_list.index(alphabet) - 1]
	else:
		return 0

def returnNext(alphabet):
	if alphabet != 'z':
		return alphabet_list[alphabet_list.index(alphabet) + 1]
	else:
		return 0
previouslength = -1
size = len(inputList)
answer = 0

def adjacent_to_previous(inputList, index):
	s = len(inputList)
	if s > 1 and index > 0 and (index < s - 1):
		if inputList[index - 1] == returnPrevious(inputList[index]) or inputList[index + 1] == returnPrevious(inputList[index]):
			return True
	if s > 1 and index == 0:
		if inputList[1] == returnPrevious(inputList[0]):
			return True
	if s > 1 and index == s - 1:
		if inputList[s - 2] == returnPrevious(inputList[s - 1]):
			return True
	return False
while previouslength != size:
	biggest_alphabet_index = -1
	if size == 1:
		break
	for (index, value) in enumerate(inputList):
		if alphabet_list.index(value) > biggest_alphabet_index and adjacent_to_previous(inputList, index):
			biggest_alphabet_index = alphabet_list.index(value)
	if biggest_alphabet_index == -1:
		break
	for (index, value) in enumerate(inputList):
		if size > 1 and index > 0 and (index < size - 1):
			if inputList[index - 1] == returnPrevious(inputList[index]) or inputList[index + 1] == returnPrevious(inputList[index]):
				if inputList[index] == alphabet_list[biggest_alphabet_index]:
					inputList[index] = 0
					answer += 1
		elif size > 1 and index == 0:
			if inputList[1] == returnPrevious(inputList[0]):
				if inputList[index] == alphabet_list[biggest_alphabet_index]:
					inputList[index] = 0
					answer += 1
		elif size > 1 and index == size - 1:
			if inputList[size - 2] == returnPrevious(inputList[size - 1]):
				if inputList[index] == alphabet_list[biggest_alphabet_index]:
					inputList[index] = 0
					answer += 1
	inputList = [i for i in inputList if i != 0]
	previouslength = size
	size = len(inputList)
print(answer)


n = int(input())
s = input()
flag = True
while flag:
	s1 = ''
	n1 = len(s)
	m = 95
	ind = -1
	for i in range(len(s)):
		k = 0
		a = ord(s[i])
		if i < n1 - 1:
			if ord(s[i + 1]) - a == -1:
				if a > m:
					m = a
					ind = i
				continue
		if i > 0:
			if ord(s[i - 1]) - a == -1:
				if a > m:
					m = a
					ind = i
				continue
	if ind == -1:
		break
	s = s[0:ind] + s[ind + 1:n1]
print(n - len(s))


def is_right_less(s, i):
	return i + 1 < len(s) and ord(s[i]) - ord(s[i + 1]) == 1

def is_left_less(s, i):
	return i - 1 >= 0 and ord(s[i]) - ord(s[i - 1]) == 1

def check_neighbours(s, i):
	if is_left_less(s, i) or is_right_less(s, i):
		return i
	else:
		return -10

def remove_neighbors(s: str) -> int:
	s = list(s)
	removed = 0
	while len(s) != 0:
		biggest_cand = -1
		remove_id = -1
		k = []
		for j in range(len(s)):
			c = check_neighbours(s, j)
			if c >= 0 and ord(s[c]) >= biggest_cand:
				k.append({c: s[c]})
				biggest_cand = ord(s[c])
				remove_id = c
		if remove_id >= 0:
			s.pop(remove_id)
			removed += 1
		else:
			break
	return removed
len_s = int(input())
s = input()
print(remove_neighbors(s))


alphabet = 'abcdefghijklmnopqrstuvwxyz'
pos = {alphabet[i]: i for i in range(26)}

def compute(s, n):
	if len(s) <= 1:
		return 0
	char = alphabet[n]
	word = []
	ans = 0
	for i in range(len(s)):
		if s[i][0] == char:
			if i != 0 and pos[s[i - 1][0]] == pos[s[i][0]] - 1 or (i != len(s) - 1 and pos[s[i + 1][0]] == pos[s[i][0]] - 1):
				ans += s[i][1]
			else:
				ans += compute(word, n - 1)
				word = []
		elif not word or word[-1][0] != s[i][0]:
			word.append(s[i])
		else:
			word[-1][1] += s[i][1]
	ans += compute(word, n - 1)
	return ans

def simplify(s):
	lst = []
	for i in range(len(s)):
		if not lst or lst[-1][0] != s[i]:
			lst.append([s[i], 1])
		else:
			lst[-1][1] += 1
	return lst
n = input()
s = simplify(input())
print(compute(s, 25))


(n, s) = (int(input()), input())

def finder():
	best = -1
	for i in range(len(s)):
		if i - 1 >= 0 and ord(s[i - 1]) + 1 == ord(s[i]) or (i + 1 < len(s) and ord(s[i + 1]) + 1 == ord(s[i])):
			if best == -1 or ord(s[best]) < ord(s[i]):
				best = i
	return best
ans = 0
best = finder()
while best != -1:
	ans += 1
	s = s[:best] + s[best + 1:]
	best = finder()
print(ans)


def pc(c):
	return chr(ord(c) - 1)
strlen = int(input())
string = input()
removalcount = 0
azindex = {chr(96 + 26 - n): [] for n in range(26)}
for (n, c) in enumerate(string):
	azindex[c].append(n)
change = True
while change:
	change = False
	for (letter, indices) in azindex.items():
		if len(indices) == 0 or letter == 'a':
			continue
		possible = -1
		for index in indices:
			if string[max(index - 1, 0)] == pc(letter) or string[min(index + 1, len(string) - 1)] == pc(letter):
				string = string[:index] + string[index + 1:]
				possible = index
				change = True
				removalcount += 1
				break
		if possible > -1:
			for letter in azindex.keys():
				newindices = []
				indices = azindex[letter]
				for index in indices:
					if index > possible:
						newindices.append(index - 1)
					elif index < possible:
						newindices.append(index)
				azindex[letter] = newindices
			break
print(removalcount)


ol = int(input())
s = [ord(x) - ord('a') for x in input()]
t = sorted(s, reverse=True)
for i in t:
	l = len(s)
	if l == 1:
		break
	for j in range(l):
		if s[j] == i:
			if j == 0:
				if abs(s[1] - i) == 1:
					s.pop(j)
					break
			elif j == l - 1:
				if abs(s[l - 2] - i) == 1:
					s.pop(j)
					break
			elif abs(s[j - 1] - i) == 1 or abs(s[j + 1] - i) == 1:
				s.pop(j)
				break
print(ol - len(s))


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():
	_ = input()
	ss = [ord(s) - ord('a') for s in input()]
	res = 0
	for c in range(26, -1, -1):
		found = True
		while c in ss and found:
			found = False
			i = 0
			while i < len(ss):
				if ss[i] == c and (i > 0 and ss[i - 1] == c - 1 or (i < len(ss) - 1 and ss[i + 1] == c - 1)):
					res += 1
					del ss[i]
					found = True
				i += 1
	print(res)
main()


n = int(input())
s = [sym for sym in input()]
unicode_code_point = 122
the_num_of_deletions = 0
s_copy = s.copy()
while unicode_code_point != 97:
	char = chr(unicode_code_point)
	previous_char = chr(unicode_code_point - 1)
	ind = 0
	while ind < len(s_copy):
		if s_copy[ind] == char:
			if 0 < ind < len(s_copy) - 1 and (s_copy[ind - 1] == previous_char or s_copy[ind + 1] == previous_char):
				del s_copy[ind]
				the_num_of_deletions += 1
			elif 0 == ind < len(s_copy) - 1 and s_copy[ind + 1] == previous_char:
				del s_copy[ind]
				the_num_of_deletions += 1
			elif 0 < ind == len(s_copy) - 1 and s_copy[ind - 1] == previous_char:
				del s_copy[ind]
				the_num_of_deletions += 1
			else:
				ind += 1
		else:
			ind += 1
	ind = len(s_copy) - 1
	while ind != -1:
		if s_copy[ind] == char:
			if 0 < ind < len(s_copy) - 1 and (s_copy[ind - 1] == previous_char or s_copy[ind + 1] == previous_char):
				del s_copy[ind]
				the_num_of_deletions += 1
			elif 0 == ind < len(s_copy) - 1 and s_copy[ind + 1] == previous_char:
				del s_copy[ind]
				the_num_of_deletions += 1
			elif 0 < ind == len(s_copy) - 1 and s_copy[ind - 1] == previous_char:
				del s_copy[ind]
				the_num_of_deletions += 1
		ind -= 1
	unicode_code_point -= 1
print(the_num_of_deletions)


n = int(input())
s = input()
ind = 0
cou = 0
while 1:
	mx = -1
	ind = -1
	for i in range(len(s)):
		if i - 1 >= 0 and ord(s[i]) == 1 + ord(s[i - 1]) or (i + 1 < len(s) and ord(s[i]) == 1 + ord(s[i + 1])):
			if ord(s[i]) > mx:
				mx = ord(s[i])
				ind = i
	if ind != -1:
		s = s[:ind] + s[ind + 1:]
		cou += 1
	else:
		break
print(cou)


import string

def prev(c):
	if c == 'a':
		return None
	return chr(ord(c) - 1)
n = int(input())
s = input()
ans = 0
for t in string.ascii_lowercase[::-1]:
	while True:
		found = False
		for i in range(len(s)):
			if t == s[i] and (i - 1 >= 0 and s[i - 1] == prev(t) or (i + 1 < len(s) and s[i + 1] == prev(t))):
				found = True
				break
		if not found:
			break
		s = s[:i] + s[i + 1:]
		ans += 1
print(ans)


n = int(input())
s = input()

def remove(s):
	actC = 'a'
	actI = -1
	for i in range(len(s)):
		if i > 0:
			if ord(s[i]) - ord(s[i - 1]) == 1 and s[i] > actC:
				actC = s[i]
				actI = i
		if i < len(s) - 1:
			if ord(s[i]) - ord(s[i + 1]) == 1 and s[i] > actC:
				actC = s[i]
				actI = i
	return (actC, actI)
ans = 0
actIdxToRem = remove(s)[1]
while actIdxToRem != -1:
	s = s[:actIdxToRem] + s[actIdxToRem + 1:]
	ans += 1
	actIdxToRem = remove(s)[1]
print(ans)


def solve_test_case(t):
	n = int(input())
	s = str(input())
	res = 0
	removed = True
	while removed:
		removed = False
		for ci in reversed(range(26)):
			c = chr(ord('a') + ci)
			prev_c = chr(ord('a') + ci - 1)
			new_s = []
			for i in range(len(s)):
				if s[i] == c:
					if i > 0 and s[i - 1] == prev_c:
						res += 1
						removed = True
						s = s[:i] + s[i + 1:]
						break
					if i < len(s) - 1 and s[i + 1] == prev_c:
						res += 1
						removed = True
						s = s[:i] + s[i + 1:]
						break
			if removed:
				break
	print(res)

def parse_array(f):
	return list(map(f, input().split()))

def solve():
	T = int(input())
	for t in range(T):
		solve_test_case(t)
solve_test_case(0)


n = int(input())
s = list(input().strip())
se = list(set(s))
c = 0
se.sort(reverse=True)
m = n
for j in range(len(se)):
	n = m - c
	k = 1
	while k < n:
		if s[k] == se[j]:
			if ord(s[k - 1]) + 1 == ord(s[k]):
				del s[k]
				c = c + 1
				n = n - 1
			else:
				k = k + 1
		else:
			k = k + 1
	n = m - c
	for k in range(n - 2, -1, -1):
		if s[k] == se[j]:
			if ord(s[k + 1]) + 1 == ord(s[k]):
				del s[k]
				c = c + 1
print(c)


import re
(n, s) = (int(input()), input())
current = ord('z')
while current - ord('a') > 0:
	previous = chr(current - 1)
	pattern = chr(current) + '*' + previous + chr(current) + '*'
	s = re.sub(pattern, previous, s)
	current -= 1
print(n - len(s))


def solve(n, string):
	string = [c for c in string]
	ans = 0

	def valid(i, char):
		if char == 'a':
			return False
		nbr = chr(ord(char) - 1)
		return i - 1 >= 0 and string[i - 1] == nbr or (i + 1 < len(string) and string[i + 1] == nbr)
	_maxxIdx = None
	while string:
		_maxxIdx = None
		for (i, c) in enumerate(string):
			if valid(i, c):
				if _maxxIdx is not None:
					if c > string[_maxxIdx]:
						_maxxIdx = i
				else:
					_maxxIdx = i
		if _maxxIdx is None:
			break
		string.pop(_maxxIdx)
	return n - len(string)
print(solve(int(input()), input()))


from collections import Counter
from collections import defaultdict as dfd
from bisect import bisect, bisect_left
from math import sqrt, gcd, ceil, factorial
from heapq import heapify, heappush, heappop
MOD = 10 ** 9 + 7
inf = float('inf')
ans_ = []

def nin():
	return int(input())

def ninf():
	return int(file.readline())

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

def stf():
	return file.readline().strip()

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

def readf():
	return list(map(int, file.readline().strip().split()))

def chk(a, b):
	return ord(b) + 1 == ord(a)

def solve():
	n = nin()
	s = st()
	ans = 0
	for i in reversed(list('abcdefghijklmnopqrstuvwxy')):
		(left, right) = (chr(ord(i) + 1) + i, i + chr(ord(i) + 1))
		while len(s) > 1 and left in s:
			ind = s.index(left)
			s = list(s)
			s.pop(ind)
			s = ''.join(s)
			ans += 1
		while len(s) > 1 and right in s:
			ind = s.index(right)
			s = list(s)
			s.pop(ind + 1)
			s = ''.join(s)
			ans += 1
	ans_.append(ans)
solve()
for i in ans_:
	print(i)


n = int(input())
a = list(map(lambda x: ord(x) - ord('a'), input()))
flag = True
flag2 = False
ans = n
mx = max(a)
while flag and len(a) and (mx > 0):
	n = len(a)
	flag = False
	for i in range(n):
		if n >= 3 and i > 0 and (i < n - 1) and (a[i + 1] == mx - 1 or a[i - 1] == mx - 1) and (a[i] == mx):
			idx = i
			flag = True
			break
		elif n >= 2 and i == 0 and (a[i + 1] == mx - 1) and (a[i] == mx):
			idx = i
			flag = True
			break
		elif n >= 2 and i == n - 1 and (a[i - 1] == mx - 1) and (a[i] == mx):
			idx = i
			flag = True
	if flag:
		a.pop(idx)
	else:
		mx -= 1
		flag2 = True
		flag = True
print(ans - len(a))


input()
s = list(input())
orig = len(s)
changed = True
while changed:
	changed = False
	for c in sorted(list(set(s)), reverse=True):
		for i in range(len(s)):
			if s[i] == c and (i - 1 >= 0 and ord(s[i - 1]) == ord(s[i]) - 1 or (i + 1 < len(s) and ord(s[i + 1]) == ord(s[i]) - 1)):
				s = s[:i] + s[i + 1:]
				changed = True
				break
		if changed:
			break
print(orig - len(s))


import atexit
import io
import sys
import math
from collections import defaultdict, Counter
n = int(input())
s = list(input())
if n == 1:
	print(0)
else:
	for j in range(122, 97, -1):
		k = 0
		while k < len(s) and len(s) > 1:
			if s[k] == chr(j - 1):
				if k == 0:
					if s[1] == chr(j):
						del s[1]
					else:
						k += 1
				elif k == len(s) - 1:
					if s[-2] == chr(j):
						del s[-2]
						k -= 1
					else:
						k += 1
				elif s[k + 1] == chr(j):
					del s[k + 1]
				elif s[k - 1] == chr(j):
					del s[k - 1]
					k -= 1
				else:
					k += 1
			else:
				k += 1
		if len(s) == 1:
			break
	print(n - len(s))


def calc(i):
	if i != 0 and ord(s[i - 1]) == ord(s[i]) - 1:
		return True
	if i != len(s) - 1 and ord(s[i + 1]) == ord(s[i]) - 1:
		return True
	return False
n = int(input())
s = list(input())
ans = 0
for i in range(122, 96, -1):
	j = 0
	while j < len(s):
		if ord(s[j]) == i and calc(j):
			ans += 1
			s.pop(j)
			j = max(0, j - 1)
		else:
			j += 1
print(ans)


n = int(input())
s = input()
ans = 0
maxs = max(s)
now = 0
while ord(maxs) > ord('a'):
	pos = s.find(maxs, now)
	if pos != -1:
		if pos - 1 >= 0 and ord(s[pos - 1]) == ord(maxs) - 1 or (pos + 1 < len(s) and ord(s[pos + 1]) == ord(maxs) - 1):
			s = s[0:pos] + s[pos + 1:len(s)]
			now = 0
			ans += 1
		else:
			now = pos + 1
	else:
		maxs = chr(ord(maxs) - 1)
		now = 0
print(ans)


n = int(input())
s = list(input())
k = 0
answer = 0
while k == 0:
	k = 1
	mas = []
	for i in range(1, len(s)):
		if ord(s[i]) - 1 == ord(s[i - 1]):
			k = 0
			mas.append([ord(s[i]), i])
		elif ord(s[i]) + 1 == ord(s[i - 1]):
			k = 0
			mas.append([ord(s[i - 1]), i - 1])
	if mas:
		mas.sort()
		answer += 1
		ind = mas[-1][1]
		s.pop(ind)
print(answer)


n = int(input())
l = input()
l3 = []
for i in l:
	l3.append(ord(i))
c = 0
for z in range(123, 97, -1):
	for i in range(len(l)):
		for j in range(len(l3) - 1):
			if l3[j] == l3[j + 1] - 1:
				if l3[j + 1] == z:
					l3.pop(j + 1)
					c += 1
					break
			elif l3[j + 1] == l3[j] - 1:
				if l3[j] == z:
					c += 1
					l3.pop(j)
					break
			else:
				continue
print(c)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 998244353
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

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

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
N = Int()
s = list(input())
a = []
removed = 0
for ind in range(25, -1, -1):
	char = ALPHA[ind]
	prev = ALPHA[ind - 1]
	if prev == 'z':
		prev = '/'
	i = 0
	last = '\\'
	a = []
	n = len(s)
	while i < len(s):
		if s[i] != char:
			a.append(s[i])
			last = s[i]
			i += 1
		else:
			c = 1
			start = i
			i += 1
			while i < n and s[i] == char:
				i += 1
				c += 1
			if last == prev or (i < n and s[i] == prev):
				removed += c
			else:
				last = char
				a.extend([char] * c)
	s = a[:]
print(removed)


import sys
input = lambda : sys.stdin.readline().rstrip()
n = int(input())
a = [100] + [ord(i) - 97 for i in input()] + [100]
alp = [i for i in range(26, -1, -1)]
for i in alp:
	j = 1
	while j < len(a) - 1:
		if a[j] == i:
			if a[j] == a[j - 1] + 1 or a[j] == a[j + 1] + 1:
				a.pop(j)
				j = 1
			else:
				j += 1
		else:
			j += 1
print(n + 2 - len(a))


from sys import stdin
input = stdin.buffer.readline
(n, s) = (int(input()), [_ - ord('a') for _ in input().rstrip()])
for v in range(25, 0, -1):
	u = v - 1
	for x in [_ for (_, w) in enumerate(s) if w == u]:
		for _ in range(x + 1, len(s)):
			if s[_] != v:
				break
			s[_] = -1
		for _ in range(x - 1, -1, -1):
			if s[_] != v:
				break
			s[_] = -1
	s = [_ for _ in s if _ != -1]
print(n - len(s))


n = int(input())
alphabet = 'abcdefghijklmnopqrstuvwxyz'
y = input()
ans = 0
for i in range(25):
	for j in range(len(y)):
		cont = True
		while cont == True:
			if j < len(y) and y[len(y) - 1 - j] == alphabet[25 - i]:
				if j < len(y) - 1 and y[len(y) - 2 - j] == alphabet[24 - i] or (j > 0 and y[len(y) - j] == alphabet[24 - i]):
					ans += 1
					m = y[:len(y) - 1 - j] + y[len(y) - j:] + '-'
					y = m
				else:
					cont = False
			else:
				cont = False
print(ans)


from sys import stdin, stdout, setrecursionlimit
input = stdin.readline
inf = float('inf')
from functools import cmp_to_key
from collections import defaultdict as dd
from collections import Counter, deque
from heapq import *
import math
from math import floor, ceil, sqrt

def geti():
	return map(int, input().strip().split())

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

def getis():
	return map(str, input().strip().split())

def getls():
	return list(map(str, input().strip().split()))

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

def geta():
	return int(input())

def print_s(s):
	stdout.write(s + '\n')

def solve():
	n = geta()
	s = list(gets())
	stack = []
	while True:
		temp = [(s[i], i) for i in range(len(s))]
		order = sorted(temp, reverse=True)
		for (char, i) in order:
			if i - 1 >= 0 and ord(char) - ord(s[i - 1]) == 1:
				del s[i]
				break
			elif i + 1 < len(s) and ord(char) - ord(s[i + 1]) == 1:
				del s[i]
				break
		else:
			break
	print(n - len(s))
solve()


n = int(input())
s = input()

def sol(s):
	n = len(s)
	if n == 1:
		return 0
	else:
		ans = 0
		m = 'a'
		ind = -1
		for i in range(n):
			(f, b) = (min(n - 1, i + 1), max(0, i - 1))
			if ord(s[i]) - ord(s[f]) == 1 or ord(s[i]) - ord(s[b]) == 1:
				if s[i] > m:
					m = s[i]
					ind = i
		if ind == -1:
			return 0
		elif ind == 0:
			v = 1 + sol(s[ind + 1:])
		elif ind == n - 1:
			v = 1 + sol(s[:n - 1])
		else:
			v = 1 + sol(s[:ind] + s[ind + 1:])
		return v
print(sol(s))


n = int(input())
n = abs(n)
s = input()
b = []
a = []
a.append(-1000000)
for i in range(n):
	b.append(ord(s[i]) - ord('a'))
maxi = -1
j = -1
while True:
	if len(b) == 1:
		break
	if b[0] == b[1] + 1:
		maxi = b[0]
		j = 0
	for i in range(1, len(b) - 1):
		if b[i] == b[i - 1] + 1 or b[i] == b[i + 1] + 1:
			if b[i] > maxi:
				maxi = b[i]
				j = i
	if b[len(b) - 1] == b[len(b) - 2] + 1:
		maxi = b[-1]
		j = len(b) - 1
	if maxi == -1:
		break
	b.pop(j)
	maxi = -1
print(n - len(b))


N = int(input())
S = input()
ans = 0
for n in range(N - 1, 0, -1):
	tmp = 0
	t = -1
	for i in range(n):
		if ord(S[i]) == ord(S[i + 1]) + 1 and tmp < ord(S[i]):
			tmp = ord(S[i])
			t = i
		if ord(S[i + 1]) == ord(S[i]) + 1 and tmp < ord(S[i + 1]):
			tmp = ord(S[i + 1])
			t = i + 1
	if t == -1:
		break
	else:
		ans += 1
		S = S[:t] + S[t + 1:]
print(ans)


m = int(input())
s = input() + '0'
num = []
le = len(s)
co = 1
for i in range(le - 1):
	if s[i] != s[i + 1]:
		num.append([ord(s[i]), co])
		co = 1
	else:
		co += 1
li = len(num)
mi = min(num)
i2 = mi[0]
for l in range(li):
	ma = max(num)
	i1 = num.index(ma)
	le = len(num)
	if le < 2 or i2 == ma[0]:
		break
	elif i1 == 0:
		if num[i1][0] == num[i1 + 1][0] + 1:
			num.remove(ma)
		else:
			num[i1][0] -= 90
	elif i1 == le - 1:
		if num[i1][0] == num[i1 - 1][0] + 1:
			num.remove(ma)
		else:
			num[i1][0] -= 90
	elif num[i1][0] == num[i1 + 1][0] + 1 or num[i1][0] == num[i1 - 1][0] + 1:
		num.remove(ma)
	else:
		num[i1][0] -= 90
	numd = []
	num.append([1, 0])
	lc = len(num)
	for i in range(lc - 1):
		if num[i][0] == num[i + 1][0]:
			num[i][1] = num[i][1] + num[i + 1][1]
			num[i + 1] = num[i]
		else:
			numd.append(num[i])
	num = numd[:]
to = 0
for i in num:
	to += i[1]
print(m - to)


n = int(input())
s = input()
ls = [s[i] for i in range(n)]
ans = 0
for i in range(25):
	x = chr(97 + 26 - i - 1)
	y = chr(97 + 26 - i - 1 - 1)
	j = 0
	while j < len(ls):
		if ls[j] == x:
			if j - 1 >= 0 and j + 1 < len(ls):
				if ls[j - 1] == y or ls[j + 1] == y:
					ans += 1
					ls.pop(j)
					j -= 1
			elif j - 1 >= 0:
				if ls[j - 1] == y:
					ans += 1
					ls.pop(j)
					j -= 1
			elif j + 1 < len(ls):
				if ls[j + 1] == y:
					ans += 1
					ls.pop(j)
					j -= 1
		j += 1
	j = len(ls) - 1
	while j >= 0:
		if ls[j] == x:
			if j - 1 >= 0 and j + 1 < len(ls):
				if ls[j - 1] == y or ls[j + 1] == y:
					ans += 1
					ls.pop(j)
			elif j - 1 >= 0:
				if ls[j - 1] == y:
					ans += 1
					ls.pop(j)
			elif j + 1 < len(ls):
				if ls[j + 1] == y:
					ans += 1
					ls.pop(j)
		j -= 1
print(ans)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import 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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
s = input()
copy = s
if n == 1:
	s = ''
	n = 0
for i in range(122, 97, -1):
	j = 0
	while j < len(s):
		if s[j] == chr(i):
			if j == 0 and j != len(s) - 1:
				if s[j + 1] == chr(i - 1):
					s = s[:j] + s[j + 1:]
				else:
					j += 1
			elif j == len(s) - 1:
				if s[j - 1] == chr(i - 1):
					s = s[:j]
				else:
					j += 1
			elif s[j - 1] == chr(i - 1):
				s = s[:j] + s[j + 1:]
			elif s[j + 1] == chr(i - 1):
				s = s[:j] + s[j + 1:]
				j -= 1
			else:
				j += 1
		else:
			j += 1
		if len(s) == 1:
			break
print(n - len(s))


(n, v) = (int(input()), 0)
s = input()
for _ in range(100):
	(max_b, max_i) = (-1, -1)
	for i in range(1, n - 1):
		(a, b, c) = (ord(s[i - 1]), ord(s[i]), ord(s[i + 1]))
		if (b == a + 1 or b == c + 1) and b > max_b:
			(max_b, max_i) = (b, i)
	if n < 2:
		break
	(b, a) = (ord(s[0]), ord(s[1]))
	if b == a + 1 and b > max_b:
		(max_b, max_i) = (b, 0)
	(b, a) = (ord(s[n - 1]), ord(s[n - 2]))
	if b == a + 1 and b > max_b:
		(max_b, max_i) = (b, n - 1)
	if max_i < 0:
		break
	else:
		v += 1
		n -= 1
		s = s[:max_i] + s[max_i + 1:]
print(v)


import os
import sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	s = list(input())
	s = [ord(x) - ord('a') for x in s]
	ans = 0
	for i in range(25, -1, -1):
		k = 0
		while k < len(s):
			if s[k] == i:
				if k - 1 >= 0 and s[k] - 1 == s[k - 1]:
					s.pop(k)
					k -= 1
					ans += 1
				if k + 1 < len(s) and s[k] - 1 == s[k + 1]:
					s.pop(k)
					k = -1
					ans += 1
			k += 1
	print(ans)
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')
main()


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin, tan

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

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

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()
n = ii()
a = lsi()
s = list(set(a))
s.sort(reverse=True)
s = s[:-1]
a = ['1'] + a + ['1']
c = 1
for i in s:
	l = 0
	while c - l:
		j = 1
		l = c
		while j < len(a):
			if a[j] == i:
				if ord(i) - ord(a[j - 1]) == 1 or ord(i) - ord(a[j + 1]) == 1:
					c += 1
					a = a[:j] + a[j + 1:]
			j += 1
print(c - 1)


import sys
import math
input = sys.stdin.readline
n = int(input())
x = input()
c = [ord(s) for s in x]
c.pop()
total = 0
while True:
	t = 0
	tv = 0
	for (i, a) in enumerate(c):
		if len(c) == 1:
			break
		if i == 0:
			if c[i] - c[i + 1] == 1:
				if c[i] > tv:
					t = i
					tv = c[i]
		elif i == len(c) - 1:
			if c[i] - c[i - 1] == 1:
				if c[i] > tv:
					t = i
					tv = c[i]
		elif c[i] - c[i - 1] == 1 or c[i] - c[i + 1] == 1:
			if c[i] > tv:
				tv = c[i]
				t = i
	if tv == 0:
		break
	if len(c) == 0:
		break
	total += 1
	del c[t]
print(total)


import sys
import math

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

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

def input():
	return sys.stdin.readline().strip()
from collections import defaultdict

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]
INF = 10 ** 18
MOD = 10 ** 9 + 7
aa = 'abcdefghijklmnopqrstuvwxyz'
A = aa[::-1]
N = int(input())
S = input()
T = [*S]
for i in range(N):
	for j in range(len(A) - 1):
		k = 0
		f = 0
		while k < len(T):
			if T[k] == A[j]:
				if len(T) == 1:
					break
				if k == 0:
					if T[k + 1] == A[j + 1]:
						del T[k]
						f = 1
						break
				elif k == len(T) - 1:
					if T[k - 1] == A[j + 1]:
						del T[k]
						f = 1
						break
				elif T[k - 1] == A[j + 1] or T[k + 1] == A[j + 1]:
					del T[k]
					f = 1
					break
			k += 1
		if f == 1:
			break
	if len(T) == 1:
		break
print(N - len(T))


import sys
input = sys.stdin.readline
from math import log2, log, ceil

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

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 swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(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
MAXN = int(1000000.0 + 5)
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')
import re
n = int(input())
s = input()
current = ord('z')
while current - ord('a') > 0:
	pre = chr(current - 1)
	pattern = chr(current) + '*' + pre + chr(current) + '*'
	s = re.sub(pattern, pre, s)
	current -= 1
print(n - len(s))


n = int(input())
s = input()
ans = 0
for i in range(25, 0, -1):
	while 1:
		c = [chr(ord('a') + i), chr(ord('a') + i - 1)]
		tmp = []
		for j in range(len(s)):
			if j > 0 and s[j] == c[0] and (s[j - 1] == c[1]):
				tmp.append(j)
			elif j < len(s) - 1 and s[j] == c[0] and (s[j + 1] == c[1]):
				tmp.append(j)
		if len(tmp) == 0:
			break
		ss = ''
		ans += len(tmp)
		for j in range(len(s)):
			if j not in tmp:
				ss += s[j]
		s = ss
print(ans)


def f(s):
	if len(s) == 1 or len(s) == 0:
		return -1
	z = -1
	for i in range(len(s)):
		if i == 0:
			if ord(s[1]) - ord(s[0]) == -1:
				if z == -1:
					z = i
				elif s[i] > s[z]:
					z = i
		elif i == len(s) - 1:
			if ord(s[-2]) - ord(s[-1]) == -1:
				if z == -1:
					z = i
				elif s[i] > s[z]:
					z = i
		elif ord(s[i - 1]) - ord(s[i]) == -1 or ord(s[i + 1]) - ord(s[i]) == -1:
			if z == -1:
				z = i
			elif s[i] > s[z]:
				z = i
	return z
n = int(input())
ss = input()
ans = 0
x = f(ss)
while x != -1:
	ss = ss[:x] + ss[x + 1:]
	ans += 1
	x = f(ss)
print(ans)


from io import StringIO
from string import ascii_lowercase as alphabet

def is_prev(ch_a, ch_b):
	return ord(ch_a) + 1 == ord(ch_b)
s_initial_len = int(input())
s = list(input())
for iter_length in range(1, len(alphabet) + 1):
	for ch_to_del in alphabet[::-1][:iter_length]:
		old_s = s.copy()
		s.clear()
		for (i, ch) in enumerate(old_s):
			if ch != ch_to_del:
				s.append(ch)
				continue
			if not (s and is_prev(s[-1], ch_to_del)):
				s.append(ch)
			if i != len(old_s) - 1:
				while s and s[-1] == ch_to_del and is_prev(old_s[i + 1], ch_to_del):
					s.pop()
print(s_initial_len - len(s))


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())
word = input()
res = 0
for ordi in range(25):
	ordinit = 122 - ordi
	while True:
		n = len(word)
		toremove = []
		if n == 1:
			break
		for i in range(n):
			if ord(word[i]) == ordinit:
				if i == 0:
					if ord(word[i]) == ord(word[i + 1]) + 1:
						if not toremove or toremove[-1] != i:
							toremove.append(i)
				elif i == n - 1:
					if ord(word[i]) == ord(word[i - 1]) + 1:
						if not toremove or toremove[-1] != i:
							toremove.append(i)
				elif ord(word[i]) == ord(word[i + 1]) + 1 or ord(word[i]) == ord(word[i - 1]) + 1:
					if not toremove or toremove[-1] != i:
						toremove.append(i)
		res += len(toremove)
		if not toremove:
			break
		counter = 0
		for i in toremove:
			word = word[:i - counter] + word[i - counter + 1:]
			counter += 1
print(res)


n = int(input())
s = input()
s = [ord(x) - ord('a') for x in s]
cur_size = n
for i in range(1, 26)[::-1]:
	j = cur_size - 1
	while j >= 0:
		if s[j] != i:
			j -= 1
			continue
		if j - 1 >= 0 and s[j - 1] == i - 1 or (j + 1 < len(s) and s[j + 1] == i - 1):
			s = s[:j] + s[j + 1:]
			cur_size -= 1
			if j == cur_size:
				j -= 1
		else:
			j -= 1
print(n - cur_size)


t = int(input())
st = input()
stlis = []
for i in range(t):
	stlis.append(ord(st[i]) - 97)
stlis.append(-10)
for i in range(25, -1, -1):
	j = 0
	while True:
		if j >= len(stlis) - 1:
			break
		if stlis[j] == i:
			try:
				if j == 0:
					if stlis[j] - 1 == stlis[j + 1]:
						stlis.pop(0)
					else:
						j = j + 1
				elif stlis[j] - 1 == stlis[j - 1] or stlis[j] - 1 == stlis[j + 1]:
					stlis.pop(j)
					j = 0
				else:
					j = j + 1
			except:
				break
		else:
			j = j + 1
print(t - len(stlis) + 1)


n = int(input())
s = input()
for _ in range(len(s)):
	mx = 0
	ind = -1
	for i in range(len(s)):
		a = -1
		b = -1
		if i > 0:
			if ord(s[i - 1]) == ord(s[i]) - 1:
				a = i
		if i + 1 < len(s):
			if ord(s[i + 1]) == ord(s[i]) - 1:
				b = i
		if a == i or b == i:
			if ord(s[i]) > mx:
				mx = ord(s[i])
				ind = i
	if ind == -1:
		break
	else:
		s = s[:ind] + s[ind + 1:]
print(n - len(s))


n = int(input())
s = input()
for i in range(122, 96, -1):
	t = 0
	while t < len(s):
		if ord(s[t]) == i:
			if t + 1 < len(s) and ord(s[t + 1]) == i - 1:
				s = s[:t] + s[t + 1:]
				if t - 2 >= 0:
					t -= 2
				elif t - 1 >= 0:
					t = -1
		t += 1
	t = 0
	while t < len(s):
		if ord(s[t]) == i:
			if t - 1 >= 0 and ord(s[t - 1]) == i - 1:
				s = s[:t] + s[t + 1:]
				t -= 1
		t += 1
print(n - len(s))


def rem(l, n):
	remo = []
	for i in range(1, n + 1):
		if l[i] == l[i - 1] + 1 or l[i] == l[i + 1] + 1:
			remo.append((l[i], i))
	remo.sort()
	return remo
n = int(input())
l = [ord(i) for i in '$' + input() + '$']
removed = rem(l, n)
x = 0
while removed:
	l.pop(removed[-1][1])
	x += 1
	removed = rem(l, n - x)
print(x)


n = int(input())
x = input()
l = [i for i in x]

def getMaxInd() -> int:
	m = '_'
	loc = -1
	for i in range(len(l) - 1):
		if abs(ord(l[i]) - ord(l[i + 1])) == 1:
			if ord(l[i]) > ord(m):
				m = l[i]
				loc = i
			if ord(m) < ord(l[i + 1]):
				m = l[i + 1]
				loc = i + 1
	return loc
q = getMaxInd()
c = 0
while q != -1:
	l.pop(q)
	c = c + 1
	q = getMaxInd()
print(c)


import math
n = int(input())
s = list(input())
for i in range(26):
	t = 122 - i
	j = 0
	for k in range(len(s)):
		for j in range(len(s)):
			if ord(s[j]) == t:
				if j > 0 and ord(s[j - 1]) == t - 1:
					s.pop(j)
					break
				elif j < len(s) - 1 and ord(s[j + 1]) == t - 1:
					s.pop(j)
					break
print(n - len(s))


n = int(input())
s = input()
a = [ord(c) for c in s]
for rmv in sorted(set(a), reverse=True):
	changed = True
	while changed:
		changed = False
		for (i, v) in enumerate(a):
			if v == rmv:
				check = (a[i - 1] if i != 0 else None, a[i + 1] if i != len(a) - 1 else None)
				if v - 1 in check:
					changed = True
					a[i] = None
					break
		if changed:
			a = list(filter(lambda x: x, a))
print(n - len(a))


import sys
input = sys.stdin.readline
Alp = [chr(i) for i in range(97, 97 + 26)]
N = int(input())
S = input().rstrip()
ans = 0
for a in reversed(Alp):
	while True:
		update = False
		for i in range(len(S)):
			if S[i] != a:
				continue
			if i != 0 and ord(S[i - 1]) == ord(a) - 1:
				S = S[:i] + S[i + 1:]
				update = True
				break
			if i != len(S) - 1 and ord(S[i + 1]) == ord(a) - 1:
				S = S[:i] + S[i + 1:]
				update = True
				break
		if not update:
			break
		ans += 1
print(ans)


def check(arr, n):
	max1 = 0
	idx = -1
	for i in range(n):
		if i == 0:
			if arr[i] - arr[i + 1] == 1 and n != 1:
				if arr[i] > max1:
					max1 = arr[i]
					idx = i
		elif i == n - 1:
			if arr[i] - arr[i - 1] == 1 and n != 1:
				if arr[i] > max1:
					max1 = arr[i]
					idx = i
		elif (arr[i] - arr[i - 1] == 1 or arr[i] - arr[i + 1] == 1) and n != 1:
			if arr[i] > max1:
				max1 = arr[i]
				idx = i
	return idx
n = int(input())
str1 = input()
arr = [0] * n
for i in range(n):
	arr[i] = ord(str1[i])
temp = n
cnt = 0
flag = 0
while flag != 1:
	if temp == 1:
		flag = 1
		break
	idx = check(arr, temp)
	if idx == -1 or temp == 1:
		flag = 1
		break
	arr.pop(idx)
	cnt += 1
	temp -= 1
print(cnt)


import sys
input = sys.stdin.readline
n = int(input())
s = ['0'] + list(input())
for i in range(25, -1, -1):
	t = chr(97 + i)
	while True:
		d = []
		for j in range(len(s)):
			if s[j] == t and (s[j - 1] == chr(97 + i - 1) or s[j + 1] == chr(97 + i - 1)):
				d.append(j)
		for j in range(len(d)):
			d[j] -= j
		for e in d:
			del s[e]
		if not d:
			break
print(n - len(s) + 2)


n = int(input())
s = [x for x in input()]
alpha = [x for x in ' abcdefghijklmnopqrstuvwxyz']
while len(s) > 1:
	maxvalue = 'a'
	maxindex = -1
	for (i, x) in enumerate(s):
		if x >= maxvalue:
			flag = False
			if i == 0:
				if s[i + 1] == alpha[alpha.index(x) - 1]:
					flag = True
			elif i == len(s) - 1:
				if s[i - 1] == alpha[alpha.index(x) - 1]:
					flag = True
			elif s[i - 1] == alpha[alpha.index(x) - 1] or s[i + 1] == alpha[alpha.index(x) - 1]:
				flag = True
			if flag:
				maxvalue = x
				maxindex = i
	if maxindex == -1:
		break
	else:
		s.pop(maxindex)
print(n - len(s))


import re
n = int(input())
a = input()
for i in range(ord('z'), ord('a'), -1):
	a = re.sub(chr(i - 1) + chr(i) + '+', chr(i - 1), a)
	a = re.sub(chr(i) + '+' + chr(i - 1), chr(i - 1), a)
print(n - len(a))


n = int(input())
s = '_' + input() + '_'
for i in range(24, -1, -1):
	c = chr(i + 1 + ord('a'))
	d = chr(i + ord('a'))
	flg = 1
	while flg:
		flg = 0
		t = ''
		for j in range(len(s) - 2):
			if s[j + 1] == c and (s[j] == d or s[j + 2] == d):
				flg = 1
			else:
				t += s[j + 1]
		s = '_' + t[:] + '_'
print(n - len(s) + 2)


n = int(input())
x = input()

def remove(tmp, x):
	removed = 0
	if len(tmp) >= 2 and tmp[0] == x and (tmp[1] == x - 1):
		removed += 1
		tmp.pop(0)
	i = 0
	n = len(tmp)
	while i < n:
		if i == 0:
			if len(tmp) >= 2 and tmp[0] == x and (tmp[1] == x - 1):
				removed += 1
				tmp.pop(0)
				n -= 1
				continue
		elif i == n - 1:
			if len(tmp) >= 2 and tmp[-1] == x and (tmp[-2] == x - 1):
				removed += 1
				tmp.pop(len(tmp) - 1)
				n -= 1
				continue
		elif tmp[i] == x and (tmp[i + 1] == x - 1 or tmp[i - 1] == x - 1):
			removed += 1
			tmp.pop(i)
			i -= 1
			n -= 1
			continue
		i += 1
	return removed

def solve(x, n):
	out = 0
	tmp = [ord(e) for e in x]
	chars = list(set(tmp[:]))
	chars.sort(reverse=True)
	for char in chars:
		out += remove(tmp, char)
	print(out)
solve(x, n)


n = int(input())
s = list(input())
for i in range(ord('z'), ord('a') - 1, -1):
	j = 0
	while j < len(s):
		if len(s) <= j:
			break
		if j == len(s) - 1:
			if s[j] == chr(i) and s[j - 1] == chr(i - 1):
				k = s.pop(j)
				j = 0
				continue
		elif j == 0:
			if s[j] == chr(i) and s[j + 1] == chr(i - 1):
				k = s.pop(j)
				j = 0
				continue
		elif s[j] == chr(i) and (s[j - 1] == chr(i - 1) or s[j + 1] == chr(i - 1)):
			k = s.pop(j)
			j = 0
			continue
		j = j + 1
print(n - len(s))


n = int(input())
s = input()
d = ['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']
s = list(s)
ans = 0
for cr in range(len(d) - 1, 0, -1):
	c = 0
	k = 0
	while c < n - k:
		if not s:
			break
		if c - 1 >= 0 and s[c] == d[cr] and (s[c - 1] == d[cr - 1]):
			s.pop(c)
			c = max(c - 1, 0)
			n -= 1
			ans += 1
		elif c + 1 < n and s[c] == d[cr] and (s[c + 1] == d[cr - 1]):
			s.pop(c)
			c = max(c - 1, 0)
			n -= 1
			ans += 1
		else:
			c += 1
print(ans)


(n, s) = (int(input()), input())
for c in 'bcdefghijklmnopqrstuvwxyz'[::-1]:
	d = True
	while d:
		d = False
		pos = [k for k in range(len(s)) if s[k] == c]
		for k in pos:
			if k + 1 < len(s) and ord(s[k + 1]) - ord(c) == -1 or (k >= 1 and ord(s[k - 1]) - ord(c) == -1):
				d = True
				s = s[:k] + s[k + 1:]
				break
print(n - len(s))


n = int(input())
arr = [199999] + [ord(i) for i in input()] + [0]
ans = 0
for i in 'abcdefghijklmnopqrstuvwxyz'[::-1]:
	rem = []
	j = 1
	while arr[j] != 0:
		if ord(i) == arr[j] and (arr[j] - 1 == arr[j - 1] or arr[j] - 1 == arr[j + 1]):
			arr.pop(j)
			j -= 1
			ans += 1
		else:
			j += 1
print(ans)


n = int(input())
s = list(input())
count = 0
temp = '*'
for i in range(0, 25):
	to_remove = chr(ord('z') - i)
	adj = chr(ord('y') - i)
	prev = 0
	while s[prev] == temp:
		prev = prev + 1
	for j in range(prev + 1, n):
		if s[j] == temp:
			continue
		if s[prev] == adj and s[j] == to_remove:
			s[j] = temp
			count += 1
		else:
			prev = j
	prev = n - 1
	while s[prev] == temp:
		prev -= 1
	for j in range(prev - 1, -1, -1):
		if s[j] == temp:
			continue
		if s[prev] == adj and s[j] == to_remove:
			s[j] = temp
			count += 1
		else:
			prev = j
print(count)


n = int(input())
s = str(input())
s = list('$' + s + '$')
char = []
for i in s:
	char.append(ord(i))
removable = []
z = len(char)
for i in range(1, n + 1):
	if char[i] == char[i - 1] + 1 or char[i] == char[i + 1] + 1:
		removable.append((char[i], i))
while len(removable) > 0:
	removable.sort()
	char.pop(removable[-1][1])
	removable = []
	for i in range(1, len(char) - 1):
		if char[i] == char[i - 1] + 1 or char[i] == char[i + 1] + 1:
			removable.append((char[i], i))
print(z - 2 - (len(char) - 2))


import gc

class Node:

	def __init__(self, data):
		self.data = data
		self.next = None
		self.prev = None

class DoublyLinkedList:

	def __init__(self):
		self.head = None

	def push(self, new_data):
		new_node = Node(new_data)
		new_node.next = self.head
		if self.head is not None:
			self.head.prev = new_node
		self.head = new_node

	def insertAfter(self, prev_node, new_data):
		if prev_node is None:
			print('the given previous node cannot be NULL')
			return
		new_node = Node(new_data)
		new_node.next = prev_node.next
		prev_node.next = new_node
		new_node.prev = prev_node
		if new_node.next is not None:
			new_node.next.prev = new_node

	def append(self, new_data):
		new_node = Node(new_data)
		new_node.next = None
		if self.head is None:
			new_node.prev = None
			self.head = new_node
			return
		last = self.head
		while last.next is not None:
			last = last.next
		last.next = new_node
		new_node.prev = last
		return

	def deleteNode(self, dele):
		if self.head is None or dele is None:
			return
		if self.head == dele:
			self.head = dele.next
		if dele.next is not None:
			dele.next.prev = dele.prev
		if dele.prev is not None:
			dele.prev.next = dele.next
		gc.collect()

	def printList(self, node):
		while node is not None:
			print(node.data, end=' ')
			node = node.next
		print()
llist = DoublyLinkedList()
llist.append(-2)
llist.append(-2)
n = int(input())
curVal = -1
for i in input():
	val = ord(i) - ord('a')
	llist.append(val)
	curVal = max(curVal, val)
llist.append(-2)
llist.append(-2)
initLen = n
curLen = n
while curVal > 0:
	temp = llist.head
	while temp != None:
		if temp.data == curVal and (temp.next != None and temp.next.data == curVal - 1):
			temp = temp.prev
			llist.deleteNode(temp.next)
			curLen -= 1
			temp = temp.prev
		elif temp.data == curVal and (temp.prev != None and temp.prev.data == curVal - 1):
			temp = temp.prev
			llist.deleteNode(temp.next)
			curLen -= 1
		temp = temp.next
	curVal -= 1
print(initLen - curLen)


import math
import re
import itertools
import copy
import time
import sys

def input_linear(lamb=lambda x: int(x), seperator=' '):
	return map(lamb, input().split(seperator))

def input_array(lamb=lambda x: int(x), seperator=' '):
	return list(map(lamb, input().split(seperator)))

def input_matrix(rows, lamb=lambda x: int(x), seperator=' '):
	tmp_matrix = []
	for i in range(rows):
		tmp_matrix.append(input_array(lamb, seperator))
	return tmp_matrix

def input_graph_al_pair(vertices, lines, lamb=lambda x: int(x), seperator=' ', directional=False, remove_dup=False):
	temp_matrix = [x[:] for x in [[]] * vertices]
	if not directional:
		if not remove_dup:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				temp_matrix[ina].append(inb)
				temp_matrix[inb].append(ina)
		else:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				if inb not in temp_matrix[ina]:
					temp_matrix[ina].append(inb)
				if ina not in temp_matrix[inb]:
					temp_matrix[inb].append(ina)
		return temp_matrix
	else:
		if not remove_dup:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				temp_matrix[ina].append(inb)
		else:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				if inb not in temp_matrix[ina]:
					temp_matrix[ina].append(inb)
		return temp_matrix
n = int(input())
a = list(input())
a = [ord(x) - ord('a') for x in a]
cnt = 0
for i in range(26, 0, -1):
	to_do = len(a)
	j = 0
	while j < to_do and len(a) > 1:
		if a[j] == i:
			if j - 1 >= 0 and a[j - 1] == i - 1:
				a.pop(j)
				cnt += 1
				to_do -= 1
				j = -1
			elif j + 1 < to_do and a[j + 1] == i - 1:
				a.pop(j)
				cnt += 1
				to_do -= 1
				j = -1
		j += 1
print(cnt)


n = int(input())
s = input()
count = 0
for _ in range(n):
	maxi = 0
	idx = -1
	lens = len(s)
	for i in range(lens - 1):
		if abs(ord(s[i]) - ord(s[i + 1])) == 1:
			if ord(s[i]) > maxi:
				maxi = ord(s[i])
				idx = i
			if ord(s[i + 1]) > maxi:
				maxi = ord(s[i + 1])
				idx = i + 1
	if idx == -1:
		break
	if idx == lens - 1:
		s = s[:idx]
	else:
		s = s[:idx] + s[idx + 1:]
	count += 1
print(count)


n = int(input())
s = input()
l = [ord(i) for i in s]
cnt = 0
while True:
	mx = -3
	flag = True
	i = 0
	index = -1
	while i < n:
		if i - 1 >= 0 and l[i] - l[i - 1] == 1 and (l[i] >= mx):
			mx = l[i]
			index = i
			flag = False
		if i + 1 < n and l[i] - l[i + 1] == 1 and (l[i] >= mx):
			mx = l[i]
			index = i
			flag = False
		i += 1
	if flag:
		break
	l[index] = -10
	l.remove(-10)
	n -= 1
	cnt += 1
print(cnt)


from sys import stdin
input = stdin.readline
n = int(input())
s = list(input().strip())
for i in range(26):
	char = chr(ord('z') - i)
	prev = chr(ord('z') - i - 1)
	updated = True
	while updated:
		updated = False
		for idx in range(len(s) - 1, -1, -1):
			if s[idx] == char:
				if idx < len(s) - 1 and s[idx + 1] == prev:
					s.pop(idx)
					updated = True
				elif idx > 0 and s[idx - 1] == prev:
					s.pop(idx)
					updated = True
print(n - len(s))


n = int(input())
s = input()
l = [ord(i) for i in s]
maxa = 0
numofc = 1
if n == 1:
	print(0)
else:
	while 1:
		numofc = 0
		lo = []
		if len(l) > 1:
			if l[0] == l[1] + 1:
				lo.append((l[0], 0))
			if l[-1] == l[-2] + 1:
				lo.append((l[-1], len(l) - 1))
			for i in range(1, len(l) - 1):
				if l[i - 1] == l[i] - 1 or l[i + 1] == l[i] - 1:
					lo.append((l[i], i))
			numofc = len(lo)
			if numofc > 0:
				maxa = max(lo)
				l.pop(maxa[1])
			else:
				break
		else:
			break
	print(len(s) - len(l))


def find(n):
	arr = [ord(i) for i in n]
	ans = 0
	for i in range(97 + 26, 96, -1):
		while True:
			temp = -1
			for j in range(len(arr)):
				if arr[j] == i and (arr[max(0, j - 1)] == i - 1 or arr[min(len(arr) - 1, j + 1)] == i - 1):
					temp = j
			if temp != -1:
				ans += 1
				arr.pop(temp)
			else:
				break
	return ans
x = int(input())
n = input()
print(find(n))


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.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('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
n = val()
s = st()
check = 'abcdefghijklmnopqrstuvwxyz'
ind = 25
while len(s) and ind > 0:
	tru = 1
	for i in range(len(s)):
		if s[i] == check[ind] and (i and s[i - 1] == check[ind - 1] or (i != len(s) - 1 and s[i + 1] == check[ind - 1])):
			s = s[:i] + s[i + 1:]
			tru = 0
			break
	ind -= tru
print(n - len(s))


import string
_ = input()
s = input()
org = len(s)
alp = string.ascii_lowercase
alp = alp[::-1]
changed = True
while changed:
	changed = False
	for ai in range(len(alp) - 1):
		for si in range(len(s)):
			if s[si] == alp[ai]:
				pa = alp[ai + 1]
				l = ''
				if si - 1 >= 0:
					l = s[si - 1]
				r = ''
				if si + 1 < len(s):
					r = s[si + 1]
				if l == pa or r == pa:
					changed = True
					s = s[:si] + s[si + 1:]
					break
		if changed:
			break
print(org - len(s))


import sys
from collections import defaultdict
p = 'abcdefghijklmnopqrstuvwxyz'
d = dict()
for i in range(26):
	d[p[i]] = i
n = int(input())
s = list(input())
m = 0
for c in reversed(p):
	while True:
		for j in range(len(s)):
			if s[j] == c and j > 0 and (d[s[j]] == d[s[j - 1]] + 1 or d[s[j]] == d[s[j - 1]] - 1):
				s[j] = 1
				s.remove(1)
				m += 1
				break
			elif s[j] == c and j < len(s) - 1 and (d[s[j]] == d[s[j + 1]] + 1 or d[s[j]] == d[s[j + 1]] - 1):
				s[j] = 1
				s.remove(1)
				m += 1
				break
		else:
			break
print(m)


import sys
import bisect
import heapq
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
n = int(ri())
s = ri()
maxx = -1
maxxind = -1
flag = True
cnt = 0
while flag:
	flag = False
	maxx = -1
	maxxind = -1
	for i in range(len(s)):
		if i - 1 >= 0 and ord(s[i]) == ord(s[i - 1]) + 1:
			if ord(s[i]) > maxx:
				maxx = ord(s[i])
				maxxind = i
				flag = True
		if i + 1 <= len(s) - 1 and ord(s[i]) == ord(s[i + 1]) + 1:
			if ord(s[i]) > maxx:
				maxx = ord(s[i])
				maxxind = i
				flag = True
	if flag:
		s = s[0:maxxind] + s[maxxind + 1:]
		cnt += 1
print(cnt)


ans = 100000000.0

def solve(x, n):
	global ans
	ans = min(ans, n)
	res = 'a'
	for i in range(n - 1):
		if abs(ord(x[i]) - ord(x[i + 1])) == 1:
			if x[i] > x[i + 1]:
				res = max(res, x[i])
			else:
				res = max(res, x[i + 1])
	if res == 'a':
		return
	for i in range(n - 1):
		if abs(ord(x[i]) - ord(x[i + 1])) == 1:
			if x[i] > x[i + 1] and x[i] == res:
				solve(x[:i] + x[i + 1:], n - 1)
				break
			elif x[i] < x[i + 1] and x[i + 1] == res:
				solve(x[:i + 1] + x[i + 2:], n - 1)
				break
n = int(input())
s = input()
solve(s, n)
print(n - ans)


from math import *
alf = list(reversed('abcdefghijklmnopqrstuvwxyz'))

def adj(a, b):
	return chr(ord(a) - 1) == b
n = int(input())
s = [i for i in input()]
for a in alf:
	i = 0
	while i < len(s):
		if s[i] == a and i > 0 and adj(s[i], s[i - 1]):
			s.pop(i)
			i = 0
		elif s[i] == a and i < len(s) - 1 and adj(s[i], s[i + 1]):
			s.pop(i)
			i = 0
		else:
			i += 1
print(n - len(s))


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

def is_next_inc(x, y):
	if x == 'z':
		return False
	return y == chr(ord(x) + 1)

def is_next_dec(x, y):
	if x == 'a':
		return False
	return y == chr(ord(x) - 1)

def main():
	l = int(input())
	s = input()
	while True:
		n = len(s)
		max_char = 'a'
		max_char_ind = -1
		for i in range(n):
			if i > 0 and (is_next_inc(s[i], s[i - 1]) or is_next_dec(s[i], s[i - 1])):
				if ord(s[i]) >= ord(max_char):
					max_char_ind = i
					max_char = s[i]
			if i < n - 1 and (is_next_inc(s[i], s[i + 1]) or is_next_dec(s[i], s[i + 1])):
				if ord(s[i]) >= ord(max_char):
					max_char_ind = i
					max_char = s[i]
		if max_char_ind == -1:
			break
		s = s[:max_char_ind] + s[max_char_ind + 1:]
	print(l - len(s))
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')
main()


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 0 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7

def cnt(ch, c):
	global a
	cn1 = cn2 = 0
	while ch in a:
		a = a.replace(ch, c, 1)
		cn1 += 1
	while ch[::-1] in a:
		a = a.replace(ch[::-1], c, 1)
		cn2 += 1
	return cn1 + cn2
n = I()
a = S()
ans = 0
for i in range(25, 0, -1):
	ans += cnt(chr(i + 97) + chr(i - 1 + 97), chr(i - 1 + 97))
print(ans)


import functools
s_len = int(input())
s = input()
assert len(s) == s_len

def adj(a, b):
	return abs(ord(a) - ord(b)) == 1

@functools.lru_cache(maxsize=None)
def max_moves(string):
	if len(string) <= 1:
		return 0
	if len(string) == 2:
		if adj(string[0], string[1]):
			return 1
		else:
			return 0
	(split, c) = max(enumerate(string), key=lambda x: x[1])
	split_end = split + 1
	while split_end < len(string) and string[split_end] == c:
		split_end += 1
	if split != 0 and adj(string[split - 1], c) or (split_end != len(string) and adj(string[split_end], c)):
		with_split = split_end - split + max_moves(string[:split] + string[split_end:])
	else:
		with_split = -1
	no_split = max_moves(string[:split]) + max_moves(string[split + 1:])
	return max(with_split, no_split)
print(max_moves(s))


def func(x):
	return ord(x) - ord('a')
n = int(input())
a = list(map(func, list(input())))
count = [0] * 26
for i in a:
	count[i] += 1
ans = 0
for i in range(25, 0, -1):
	if count[i]:
		j = 0
		while j < n:
			if a[j] == i and (j > 0 and a[j - 1] == i - 1 or (j < n - 1 and a[j + 1] == i - 1)):
				ans += 1
				a = a[:j] + a[j + 1:]
				n -= 1
				j = -1
			j += 1
print(ans)


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n,) = I()
s = '#' + input() + '#'
cur = max(s)
ok = 0
ans = 0
while cur > 'a':
	prev = chr(ord(cur) - 1)
	d = []
	cur_s = '#'
	for i in range(1, len(s) - 1):
		if s[i] == cur and (s[i - 1] == prev or s[i + 1] == prev):
			d.append(i)
			ok += 1
		else:
			cur_s += s[i]
	if not d:
		cur = prev
	s = cur_s + '#'
if ok > ans:
	ans = max(ans, ok)
print(ans)


from sys import stdin, stdout
import traceback
import math
from collections import Counter
read = stdin.readline
write = stdout.write
writeln = lambda x: write(str(x) + '\n')

def reads(typ=int):
	return list(map(typ, read().split()))

class Sol:

	@classmethod
	def input(cls):
		s = cls()
		return s

	def solve(self):
		n = int(read())
		s = read().strip()
		self.s = s
		counts = [0] * 26
		for c in s:
			i = ord(c) - ord('a')
			counts[i] += 1
		for i in range(25, 0, -1):
			if counts[i] == 0:
				continue
			self.try_remove(i, counts[i])
		return n - len(self.s)

	def try_remove(self, ci, count):
		while self.try_remove_one(ci) and count:
			count -= 1

	def try_remove_one(self, ci):
		s = self.s
		ch = chr(ci + ord('a'))
		chl = chr(ci - 1 + ord('a'))
		for (i, c) in enumerate(s):
			if c != ch:
				continue
			if i > 0 and s[i - 1] == chl:
				self.s = s[:i] + s[i + 1:]
				return True
			if i + 1 < len(self.s) and s[i + 1] == chl:
				self.s = s[:i] + s[i + 1:]
				return True
		return False

def __starting_point():
	try:
		writeln(Sol.input().solve())
	except Exception as e:
		print('Got exception:', repr(e))
		print(traceback.format_exc())
__starting_point()


import sys
n = int(sys.stdin.readline())
rem = n
s = sys.stdin.readline()[:-1]
z = True
prev = '.'
while z:
	prev = '.'
	ind = -1
	n = len(s)
	for i in range(n):
		if i - 1 >= 0:
			if ord(s[i]) - ord(s[i - 1]) == 1:
				if ord(s[i]) > ord(prev):
					prev = s[i]
					ind = i
		if i + 1 < n:
			if ord(s[i]) - ord(s[i + 1]) == 1:
				if ord(s[i]) > ord(prev):
					prev = s[i]
					ind = i
	new_s = s[:ind] + s[ind + 1:]
	if ind == -1:
		z = False
	else:
		s = new_s
print(rem - len(s))


import sys
input = sys.stdin.readline
n = int(input())
robo = [30] + [ord(i) - 97 for i in input() if i != '\n'] + [30]
char = [i for i in range(26, -1, -1)]
for i in char:
	j = 1
	while j < len(robo) - 1:
		if robo[j] == i:
			if robo[j] == robo[j - 1] + 1 or robo[j] == robo[j + 1] + 1:
				robo.pop(j)
				j = 1
			else:
				j += 1
		else:
			j += 1
print(n + 2 - len(robo))


n = int(input())
s = [i for i in input()]
q = []

def ok(st, t):
	if len(st) == 1:
		return True
	if st[0] == t and ord(st[0]) - ord(st[1]) == 1 or (st[-1] == t and ord(st[-1]) - ord(st[-2]) == 1):
		return False
	for i in range(1, len(st) - 1):
		if st[i] == t:
			if ord(st[i]) - ord(st[i - 1]) == 1 or ord(st[i]) - ord(st[i + 1]) == 1:
				return False
	return True
for i in range(122, 96, -1):
	if len(s) == 1:
		break
	while not ok(s, chr(i)):
		q = []
		for j in range(len(s) - 1, -1, -1):
			if s[j] == chr(i):
				if j == 0 and s[1] == chr(i - 1):
					continue
				elif j == len(s) - 1 and s[len(s) - 2] == chr(i - 1):
					continue
				elif j > 0 and j < len(s) - 1 and (s[j + 1] == chr(i - 1) or s[j - 1] == chr(i - 1)):
					continue
				else:
					q.append(s[j])
			else:
				q.append(s[j])
		q = q[::-1]
		s = q.copy()
print(n - len(s))


def solve(s):
	d = 0
	for ss in sorted(set(s), reverse=True):
		while True:
			n = len(s)
			ns = list()
			succ = False
			for idx in range(len(s)):
				if s[idx] == ss and (s[max(0, idx - 1)] + 1 == s[idx] or s[min(n - 1, idx + 1)] + 1 == s[idx]):
					d += 1
					succ = True
				else:
					ns.append(s[idx])
			s = ns
			if not succ:
				break
	return d
N = int(input())
s = list(map(ord, list(input())))
print(solve(s))


n = int(input())
s = input()
c = []
for x in s:
	c.append(ord(x))
MAX = None
while MAX != -1 and len(c) != 1:
	MAX = max(c)
	success = False
	for (i, x) in enumerate(c):
		if MAX == x:
			if i == 0:
				if c[i + 1] == MAX - 1:
					del c[i]
					success = True
					break
			elif i == len(c) - 1:
				if c[i - 1] == MAX - 1:
					del c[i]
					success = True
					break
			elif MAX - 1 in [c[i - 1], c[i + 1]]:
				del c[i]
				success = True
				break
	if success == False:
		for (i, x) in enumerate(c):
			if x == MAX:
				c[i] = -1
print(n - len(c))


import os
import io
from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce
from collections import deque
import threading

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 removemax(s):
	n = len(s)
	maxi = -float('inf')
	toremove = -1
	for i in range(n):
		if i == 0 and i < n - 1 and (s[i] - s[i + 1] == 1) and (s[i] > maxi):
			toremove = i
			maxi = s[i]
		elif i == n - 1 and s[i] - s[i - 1] == 1 and (s[i] > maxi):
			toremove = i
			maxi = s[i]
		elif 0 < i < n - 1 and (s[i] - s[i - 1] == 1 or s[i] - s[i + 1] == 1) and (s[i] > maxi):
			toremove = i
			maxi = s[i]
	if toremove == -1:
		return ('', False)
	else:
		s.pop(toremove)
		return (s, True)
n = iinput()
s = list(input())
s = [ord(i) for i in s]
flag = True
ans = 0
while flag:
	(s, flag) = removemax(s)
	ans += 1
print(ans - 1)


n = int(input())
actual = n
s = input()
for i in range(100):
	n = len(s)
	ind = -1
	big = 0
	for i in range(n):
		L = 0
		R = 0
		curr = ord(s[i])
		if i - 1 >= 0:
			L = ord(s[i - 1])
		if i + 1 < n:
			R = ord(s[i + 1])
		if curr == L + 1 or curr == R + 1:
			if curr > big:
				big = curr
				ind = i
	if ind > -1:
		s = s[:ind] + s[ind + 1:]
print(actual - len(s))


n = int(input())
s = input()
for i in range(121, 96, -1):
	s1 = True
	while s1:
		s1 = False
		if len(s) == 1:
			break
		for j in range(len(s)):
			if j == 0:
				if s[j] == chr(i) and s[j + 1] == chr(i + 1):
					s = s[:j + 1] + s[j + 2:]
					s1 = True
					break
			elif j == len(s) - 1:
				if s[j] == chr(i) and s[j - 1] == chr(i + 1):
					s = s[:j - 1] + s[j:]
					s1 = True
					break
			else:
				if s[j] == chr(i) and s[j + 1] == chr(i + 1):
					s = s[:j + 1] + s[j + 2:]
					s1 = True
					break
				if s[j] == chr(i) and s[j - 1] == chr(i + 1):
					s = s[:j - 1] + s[j:]
					s1 = True
					break
print(n - len(s))


import sys
input = sys.stdin.readline
n = int(input())
s = [*map(ord, input().rstrip())]
v = [(x, i) for (i, x) in enumerate(s)]
v.sort()
ans = 0
i = n - 1
while i >= 0:
	(u, id) = v[i]
	if 1 <= id and s[id - 1] == u - 1 or (id + 1 < len(s) and s[id + 1] == u - 1):
		s.pop(id)
		v = sorted(((x, i) for (i, x) in enumerate(s)))
		i = len(s) - 1
		ans += 1
	else:
		i -= 1
print(ans)


import heapq
from sys import stdin
input = stdin.readline

def func():
	ans = 0
	count = 0
	if n == 1:
		print(0)
		return
	while True:
		heap = []
		for i in range(len(s)):
			heap.append((-ord(s[i]), i))
		heapq.heapify(heap)
		while heap:
			(ele, ind) = heapq.heappop(heap)
			if ind == 0:
				if ord(s[ind + 1]) == -ele - 1:
					s.pop(ind)
					count += 1
					break
			elif ind == len(s) - 1:
				if ord(s[ind - 1]) == -ele - 1:
					s.pop(ind)
					count += 1
					break
			elif ord(s[ind + 1]) == -ele - 1 or ord(s[ind - 1]) == -ele - 1:
				s.pop(ind)
				count += 1
				break
		ans = ans + count
		if len(s) <= 1 or count == 0:
			break
		count = 0
	print(ans)
n = int(input())
s = list(input().rstrip())
func()


import sys
import copy
input = sys.stdin.readline
from math import *
n = int(input())
s = list(input().rstrip())
p = copy.deepcopy(s)
q = copy.deepcopy(s)
r = copy.deepcopy(s)
c1 = 0
j = n - 1
if len(s) == 1:
	print(0)
	exit(0)
w = set(s)
w = list(s)
w.sort(reverse=True)
for i in range(len(w)):
	for j in range(n):
		k = 0
		while k < len(s):
			if s[k] == w[i]:
				if -ord(s[max(0, k - 1)]) + ord(s[k]) == 1 or -ord(s[min(len(s) - 1, k + 1)]) + ord(s[k]) == 1:
					s.pop(k)
					c1 += 1
				else:
					k += 1
			else:
				k += 1
print(c1)


n = int(input())
s = input()
ans = 0
done = True
while done:
	done = False
	ind = -1
	char = 0
	for i in range(len(s)):
		if i - 1 >= 0 and ord(s[i]) - ord(s[i - 1]) == 1:
			done = True
			if ord(s[i]) > char:
				char = ord(s[i])
				ind = i
		if i + 1 < len(s) and ord(s[i]) - ord(s[i + 1]) == 1:
			done = True
			if ord(s[i]) > char:
				char = ord(s[i])
				ind = i
	if done:
		s = s[:ind] + (s[ind + 1:] if ind + 1 < len(s) else '')
		ans += 1
print(ans)


import string
n = int(input())
s = list(input())
letters = list(string.ascii_lowercase)
count = 0
for i in range(len(letters) - 1, 0, -1):
	j = len(s) - 1
	while j >= 0:
		if j < len(s) and s[j] == letters[i]:
			if j + 1 < len(s) and s[j + 1] == letters[i - 1] or (j - 1 >= 0 and s[j - 1] == letters[i - 1]):
				count += 1
				s.pop(j)
				j += 1
		j -= 1
print(count)


n = int(input())
s = input()
if n == 1:
	print(0)
else:
	alph = 'abcdefghijklmnopqrstuvwxyz'
	while True:
		if len(s) == 1:
			break
		mx = 'a'
		index = -1
		for i in range(1, len(s) - 1):
			if s[i] > mx and (alph[alph.find(s[i]) - 1] == s[i - 1] or alph[alph.find(s[i]) - 1] == s[i + 1]):
				mx = max(mx, s[i])
				index = i
		if s[0] > mx and alph[alph.find(s[0]) - 1] == s[1]:
			index = 0
			mx = s[0]
		if s[-1] > mx and alph[alph.find(s[-1]) - 1] == s[-2]:
			index = len(s) - 1
			mx = alph[alph.find(s[-1]) - 1]
		if index == -1:
			break
		else:
			s = s[:index] + s[index + 1:]
	print(n - len(s))


import os
n = int(input())
s = input()
l = n
b = [[chr(x), s.count(chr(x))] for x in range(97, 123)]
b.insert(0, ['%', 0])
s = '#' + s + '#'
s = list(s)
while len(b) > 1:
	dil = 1
	while b[-1][1] and dil:
		y = b[-1][0]
		dil = 0
		for i in range(1, len(s) - 1):
			try:
				if s[i] == y:
					if s[i - 1] == b[-2][0] or s[i + 1] == b[-2][0]:
						dil += 1
						s.pop(i)
						b[-1][1] -= 1
			except:
				break
	b.pop(-1)
print(l - len(s) + 2)


n = int(input())
s = [ord(i) - 97 for i in input()]
ans = 0
while 1:
	mxi = mx = -1
	for i in range(len(s)):
		if i and s[i - 1] == s[i] - 1 and (s[i] > mx):
			mx = s[i]
			mxi = i
		if i + 1 < len(s) and s[i + 1] == s[i] - 1 and (s[i] > mx):
			mx = s[i]
			mxi = i
	if mx == -1:
		break
	ans += 1
	s.pop(mxi)
print(ans)


q = int(input())
arr = [ord(i) for i in input()]
count = 0
max1 = max(arr)
while max1 != 0:
	max1 = max(arr)
	temp = []
	for x in range(len(arr)):
		if x == 0:
			if arr[x] == max1 and len(arr) != 1:
				if arr[x + 1] == max1 - 1:
					temp.append(x)
					count += 1
		elif x == len(arr) - 1:
			if arr[x] == max1 and len(arr) != 1:
				if arr[x - 1] == max1 - 1:
					temp.append(x)
					count += 1
		elif arr[x] == max1:
			if arr[x - 1] == max1 - 1 or arr[x + 1] == max1 - 1:
				temp.append(x)
				count += 1
	for each in reversed(temp):
		arr.pop(each)
	if len(temp) == 0:
		for x in range(len(arr)):
			if arr[x] == max1:
				arr[x] = 0
print(count)


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
from io import BytesIO, IOBase
from bisect import bisect_left

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def modpow(b, p, m):
	res = 1
	b = b % m
	while p:
		if p & 1:
			res = res * b % m
		b = b * b % m
		p >>= 1
	return res

def mod_inv(a, m):
	return modpow(a, m - 2, m)

def ncr(n, r, m):
	res = 1
	if r == 0:
		return 1
	if n - r < r:
		r = n - r
	(p, k) = (1, 1)
	while r:
		res = res % m * (n % m * mod_inv(r, m) % m) % m
		n -= 1
		r -= 1
	return res

def ncrlis(n, r, m, fact):
	return fact[n] * (mod_inv(fact[r], m) * mod_inv(fact[n - r], m)) % m % m

def ceil(n, k):
	return n // k + (n % k != 0)

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

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

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

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

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
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')
n = ii()
s = list(input())
s = ['#'] + s + ['#']
alph = '$abcdefghijklmnopqrstuvwxyz$'
lis = list(set(s))
lis.sort(reverse=True)
for i in lis:
	j = 1
	while j < len(s) - 1:
		if s[j] == i:
			if s[j + 1] == alph[ord(i) - 97] or s[j - 1] == alph[ord(i) - 97]:
				s.pop(j)
				j = 1
			else:
				j += 1
		else:
			j += 1
print(n - len(s) + 2)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

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')
import collections as col
import math, string

def getInts():
	return [int(s) for s in input().split()]

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

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	S = getStr()
	alpha = list(string.ascii_lowercase)[::-1]
	ans = 0
	for letter in alpha:
		if letter == 'a':
			break
		prev = chr(ord(letter) - 1)
		while prev + letter in S or letter + prev in S:
			ans += 1
			if prev + letter in S:
				idx = S.find(prev + letter)
				S = S[:idx + 1] + S[idx + 2:]
			else:
				idx = S.find(letter + prev)
				S = S[:idx] + S[idx + 1:]
	return ans
print(solve())


w = 'abcdefghijklmnopqrstuvwxyz'
q = int(input())
p = q
a = list(input())
e = [1]
r = w.index(max(a))
while r:
	e = []
	for i in range(q):
		if a[i] == w[r]:
			if i > 0 and a[i - 1] == w[r - 1]:
				e.append(i)
			elif i < q - 1 and a[i + 1] == w[r - 1]:
				e.append(i)
	t = 0
	for i in e:
		del a[i - t]
		t += 1
	q = len(a)
	if not e:
		r -= 1
print(p - len(a))


n = int(input())
s = str(input())
s = list(s)
n = len(s)
count = [[] for i in range(26)]
for i in range(n):
	count[ord(s[i]) - ord('a')].append(i)
start = 25
total = 0
while True:
	if start <= 0:
		break
	if len(count[start]) == 0:
		start = start - 1
		continue
	for i in range(len(count[start])):
		indexStart = count[start][i]
		indexBack = indexStart - 1
		indexFront = indexStart + 1
		b1 = 0
		b2 = 0
		while indexBack >= 0:
			if s[indexBack] != '.' and ord(s[indexBack]) - ord('a') != start:
				b1 = 1
				break
			indexBack = indexBack - 1
		while indexFront < n:
			if s[indexFront] != '.' and ord(s[indexFront]) - ord('a') != start:
				b2 = 1
				break
			indexFront = indexFront + 1
		if b1 == 1:
			if ord(s[indexBack]) - ord('a') == start - 1:
				s[indexStart] = '.'
				total = total + 1
				continue
		if b2 == 1:
			if ord(s[indexFront]) - ord('a') == start - 1:
				s[indexStart] = '.'
				total = total + 1
				4
	start = start - 1
print(total)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

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

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

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

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
n = iinp()
s = list(inp())
c = 0
S = 'zyxwvutsrqponmlkjihgfedcba'
md = {}
for i in range(26):
	md[S[i]] = 26 - i
j = 0
while j < 26:
	l = S[j]
	flg = True
	i = 0
	while i < n:
		t = False
		if s[i] == l and i != 0 and (md[s[i - 1]] == md[s[i]] - 1):
			t = True
		if s[i] == l and i != n - 1 and (md[s[i + 1]] == md[s[i]] - 1):
			t = True
		if t:
			s.pop(i)
			flg = False
			i -= 1
			n -= 1
			c += 1
		i += 1
	if flg:
		j += 1
print(c)