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.

The only 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.

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

NoteThe 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.

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(s)
print(c1)

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
					else:
						if 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))

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))

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)

import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

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

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)

    def ints(self, a):
        print(" ".join([str(_) for _ in a]))

    def intsNL(self, a):
        for _ in a:
            print(_)

    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

n = In.int()
s = In.str()

ans = 0
for i in range(25, 0, -1):
    c = chr(i+ord('a'))
    prev = chr(i+ord('a')-1)

    j = len(s)-1
    while j>=0:
        if s[j]==c:
            fitRight = j<len(s)-1 and s[j+1] == prev
            fitLeft  = j>0 and s[j-1] == prev

            if fitRight or fitLeft:
                s = s[0:j] + s[j+1::]
                ans+=1

                if j!=len(s):
                    j+=1

        j-=1

Out.int(ans)

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

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
# print(l, s)
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)

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

n = int(input())
ar = list(input())
for i in range(ord('z'), ord('a'), -1):
    for z in range(100):
        kek = []
        for j in range(len(ar) - 1):
            if ar[j] == chr(i) and ar[j + 1] == chr(i - 1):
                pass
            else:
                kek.append(ar[j])
        kek.append(ar[-1])
        ar = kek.copy()
        kek = [ar[0]]
        for j in range(1, len(ar)):
            if ar[j] == chr(i) and ar[j - 1] == chr(i - 1):
                pass
            else:
                kek.append(ar[j])
        ar = kek.copy()
print(n - len(ar))

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
        else:
            if(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(raw_input())
s=raw_input()
cnt=0

while len(s)>1:
	mx,pos=0,-1
	for i in xrange(len(s)):
		if i>0:
			if s[i]==chr(ord(s[i-1])+1):
				if s[i]>mx: mx,pos=s[i],i
		if i<len(s)-1:
			if s[i]==chr(ord(s[i+1])+1):
				if s[i]>mx: mx,pos=s[i],i
	if pos==-1: break
	else: s=s[:pos]+s[(pos+1):]
	cnt+=1

print cnt

n = int(input())
s = input()
i=0
a = 'a'
ind = -1
f = True
#print(ord(a),ord('z'))
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
		else:
			if 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
	#print(a,ind)
	if ind !=  -1:
		if ind+1 != len(s):
			s = s[0:ind] + s[ind+1:]
		else:
			s = s[0:ind]
		#print(s)
	else:
		f = False
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)

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):
    # print(i)
    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))

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())
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
    #print(*a)
    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
        #print(x,j,y,len(a),a)
        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()
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))

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):
    #print(s,i)
    s = function(s,chr(122-i));
    #print(s,i)
print(n-len(s))

import sys
# sys.setrecursionlimit(10**6)
from sys import stdin, stdout
import bisect            #c++ upperbound
import math
import heapq
def modinv(n,p):
    return pow(n,p-2,p)
def cin():
    return map(int,sin().split())
def ain():                           #takes array as input
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
import math
def Divisors(n) :
    l = []
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) :
            if (n // i == i) :
                l.append(i)
            else :
                l.append(i)
                l.append(n//i)
    return l

"""*******************************************************"""
def main():
    n=inin()
    s=sin()
    a=list(s)
    x=ord("a")
    ans=0
    for i in range(26):
        y=chr(x+25-i)
        n=len(a)
        for j in range(n):
            if(a[j]==y):
                if(j>0 and (a[j-1]==chr(ord(y)-1) or a[j-1]=="*")):
                    a[j]="*"
                    ans+=1
                elif(j<n-1 and (a[j+1]==chr(ord(y)-1) or a[j+1]=="*")):
                    a[j]="*"
                    ans+=1
        for j in range(n-1,-1,-1):
            if(a[j]==y):
                if(j>0 and (a[j-1]==chr(ord(y)-1) or a[j-1]=="*")):
                    a[j]="*"
                    ans+=1
                elif(j<n-1 and (a[j+1]==chr(ord(y)-1) or a[j+1]=="*")):
                    a[j]="*"
                    ans+=1
        a[:] = (value for value in a if value != "*")
        # print(a)
    print(ans)
######## Python 2 and 3 footer by Pajenegod and c1729

# Note because cf runs old PyPy3 version which doesn't have the sped up
# unicode strings, PyPy3 strings will many times be slower than pypy2.
# There is a way to get around this by using binary strings in PyPy3
# but its syntax is different which makes it kind of a mess to use.

# So on cf, use PyPy2 for best string performance.

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')

# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'

# Read all remaining integers in stdin, type is given by optional argument, this is fast
def readnumbers(zero = 0):
    conv = ord if py2 else lambda x:x
    A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()
    try:
        while True:
            if s[i] >= b'0' [0]:
                numb = 10 * numb + conv(s[i]) - 48
            elif s[i] == b'-' [0]: sign = -1
            elif s[i] != b'\r' [0]:
                A.append(sign*numb)
                numb = zero; sign = 1
            i += 1
    except:pass
    if s and s[-1] >= b'0' [0]:
        A.append(sign*numb)
    return A

if __name__== "__main__":
  main()

#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)
#from __future__ import print_function, division    #while using python2

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():
    #sys.stdin = open('input.txt', 'r')
    #sys.stdout = open('output.txt', 'w')

    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(max_char, s)
        # input()

    print(l -len(s))

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

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')

if __name__ == '__main__':
   main()

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(raw_input())
s=raw_input()
cnt=0

while len(s)>1:
	mx,pos=0,-1
	for i in xrange(len(s)):
		if i==0 and len(s)>1:
			if s[0]==chr(ord(s[1])+1):
				if s[0]>mx: mx,pos=s[0],0
		elif i==len(s)-1:
			if s[i]==chr(ord(s[i-1])+1):
				if s[i]>mx: mx,pos=s[i],i
		else:
			if s[i]==chr(ord(s[i-1])+1):
				if s[i]>mx: mx,pos=s[i],i
			elif s[i]==chr(ord(s[i+1])+1):
				if s[i]>mx: mx,pos=s[i],i
	if pos==-1:
		break
	else:
		s=s[:pos]+s[(pos+1):]
	cnt+=1

print cnt

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: # O(n)
        biggest_cand = -1
        remove_id = -1
        k = []
        for j in range(len(s)):  # O(n)
            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)  # O(n)
            removed += 1
        else:
            break

    return removed

len_s = int(input())
s = input()
print(remove_neighbors(s))

# sum = O(n(n+n)) = O(n*2n) = O(2n^2) = O(n^2)

import sys
n=int(sys.stdin.readline())
rem=n
s=sys.stdin.readline()[:-1]
z=True
prev = '.'
while z:
    #print(s,'s')
    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))

n = int(input())
s = input()
mas = []
cou = []
for i in range(n):
	mas.append(ord(s[i]) - ord('a'))
	cou.append([ord(s[i]) - ord('a'), i])
cou.sort()
ans = 0
while cou != []:
	d = [cou[-1]]
	del(cou[-1])
	while cou != [] and cou[-1][0] == d[0][0]:
		d.append(cou[-1])
		del(cou[-1])
	f = True
	while f:
		f = False
		for i in range(len(d)):
			now = d[i][1]
			x = mas[now]
			if x == -10:
				continue
			flag = False
			for j in range(now - 1, -1, -1):
				if mas[j] == x - 1:
					flag = True
					break
				elif mas[j] != -10:
					break
			for j in range(now + 1, n):
				if mas[j] == x - 1:
					flag = True
					break
				elif mas[j] != -10:
					break
			if flag:
				mas[now] = -10
				ans += 1
				f = True
print (ans)

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))

if __name__ == "__main__":
    main()

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)

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

# sys.setrecursionlimit(2000000)
# input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

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(1e9)+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)))

# ----------------------------------------------------
# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')

def removemax(s):
    # remove maximum element first
    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

if __name__ == "__main__":
    n = iinput()
    s = list(input())
    s = [ord(i) for i in s]
    flag = True
    ans = 0
    while flag:
        s, flag = removemax(s)
        # print('hello')
        ans += 1
    print(ans-1)

#for _ in range(int(input())):
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(s)

#print(s)
print(n-len(s))

from math import *
# from sys import stdin,stdout

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

# def ceil(a,b):
# 	if a%b == 0:
# 		return int(a/b)
# 	else:
# 		return (a//b + 1)

# from collections import deque

# n,m,k=map(int,input().split())
# ar=list(map(int,input().split()))

# q=[]
# sm=[0]*(m+1)
# for i in range(m+1):
# 	queue = deque()
# 	q.append(queue)

# ans=1
# for i in range(m+1)
# 	q[ar[i]].append(i)
# 	if(len(sm[ar[i]])==0):
# 		sm[ar[i]].append(1)
# 	else:

# 	while q[ar[i]]:

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
			# print(x,y,s[j],s)
			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)

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 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(1e9)+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(s)
print(n-len(s))

n1=input()
s=raw_input()
for _ in range(122,97,-1):
    n2=len(s)
    for k in range(n2):
        c=chr(_)
        a=""
        n=len(s)
        if n==1:
            break
        for i in range(n):
            if s[i]==c:
                if i==0:
                    if s[i+1]==chr(_-1):
                        pass
                    else:
                        a+=s[i]
                elif i==n-1:
                    if s[i-1]==chr(_-1):
                        pass
                    else:
                        a+=s[i]
                else:
                    if s[i+1]==chr(_-1):
                        pass
                    elif s[i-1]==chr(_-1):
                        pass
                    else:
                        a+=s[i]
            else:
                a+=s[i]
        s=a
print n1-len(s)

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)

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))

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 = 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))

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()
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
        else:
            if (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)]

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
#print('print(k, res, que, e_n_r, e_n_l, used, ng, nums)')
def f(k):
    global res, que, e_n_r, e_n_l, used, nums, alf, s, n
    i = alf.index(s[k])
#    print(k, res, que, e_n_r, e_n_l, used, nums)
    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]:
#        print(ng[0], ng[1], 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
#    print(k, res, que, e_n_r, e_n_l, used, ng, nums)

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)

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))

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()

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))

if __name__ == "__main__":
    main()

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))

# Legends Always Come Up with Solution
# Author: Manvir Singh

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 range(25,0,-1):
            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))

# region fastio
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

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

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

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

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

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()

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=input()
n1=n
s=raw_input().strip()
s=[ord(i) for i in s]
i=122
while i>=97:
    f=1
    while f:
        f1=0
        for j in range(n):
            if s[j]==i and ( (j>0 and s[j]-s[j-1]==1) or (j<n-1 and s[j]-s[j+1]==1)):
                f1=1
                s=s[:j]+s[j+1:]
                n=len(s)
                break
        if not f1:
            f=0
            i-=1
print n1-n

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
                else:
                    if 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)

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)

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
        else:
            if(ans<va[i]):
                ind = i
                ans = va[i]
    return ind
mi = findmax(v)
while(mi!=-1):
    #print(v, me)
    #mi = v.index(me)
    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)

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):
    #print(s,i)
    s = function(s,chr(122-i));
    #print(s,i)
print(n-len(s))

from math import *
import sys
from queue import *

n = int(input())
s = input()
a = [0]
for c in s:
    a.append(ord(c))
a.append(10000)
f = True
ans = 0
while f:
    f = False
    mx = 0
    ind = -1
    for i in range(1, len(a) - 1):
        if (a[i] - 1 == a[i - 1] or a[i] - 1 == a[i + 1]) and mx < a[i]:
            mx = a[i]
            f = True
            ind = i
    if f:
        ans += 1
        a = a[:ind] + a[ind + 1:]
print(ans)

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))

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
    # InverseofNumber(mod)
    # InverseofFactorial(mod)
    # factorial(mod)
    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))

    #<--Solving Area Ends
    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

if __name__ == '__main__':
    sys.stdin = FastStdin()
    sys.stdout = FastStdout()
    main()

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)
    stack = [s[0]] * 2
    for i in range(len(s)):
        if s[i] != stack[-1]:
            stack.append(s[i])
        if c + ord('a') == ord(s[i]) and ord(s[i]) - ord(stack[-2]) == 1:
            deleted[i] = True
    stack = [s[-1]] * 2
    for i in range(len(s) - 1, -1, -1):
        if s[i] != stack[-1]:
            stack.append(s[i])
        if c + ord('a') == ord(s[i]) and ord(s[i]) - ord(stack[-2]) == 1:
            deleted[i] = True
    s = filtered(s, deleted)
print(n - len(s))

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))

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))
		# print(chr(ord(s[i])), ord(s[i]))
		if s[nb[0]]==chr(ord(s[i])-1) or s[nb[1]]==chr(ord(s[i])-1):
			rm_ls.append(i)
	# print(rm_ls, rm, s)
	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:]
	# print(rm_ls, mx, s[mx], s)
	rm+=1
	s = new_s
	if new_s=='':
		break
print(rm)

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()

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)

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()

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
			else:
				if 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
n=int(sys.stdin.readline())
rem=n
s=sys.stdin.readline()[:-1]
z=True
prev = '.'
while z:
    #print(s,'s')
    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))

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)

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(s)
print(c1)

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))

#import io, os
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
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)

n = int(input())
s = input()
alph = list(set(s))
alph.sort(reverse=True)
s = list(s)
for i in alph:
    if i == alph[-1]:
        continue
    prev = -1
    cur = len(s)
    while prev != cur:
        j = 0
        while j < len(s):
            if s[j] == i:
                if j == 0:
                    if s[j + 1] == chr(ord(i) - 1):
                        s.pop(j)
                elif j == len(s) - 1:
                    if s[j - 1] == chr(ord(i) - 1):
                        s.pop(j)
                elif cur >= 3 and (s[j - 1] == chr(ord(i) - 1) or s[j + 1] == chr(ord(i) - 1)):
                    s.pop(j)
                    j -= 1
            j += 1
        prev = cur
        cur = len(s)
print(n - len(s))

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=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))

import sys
import math
read = lambda: list(map(int, sys.stdin.readline().strip().split()))

n = int(input())
s = input()
a = []
for i in range(n):
    a.append(s[i])
mark = [0]*26
for num in a:
    mark[ord(num)-97] += 1
cur = 25
flag = True
while len(a) > 1:
    if cur > 0 and mark[cur] == 0:
        while cur > 0 and mark[cur] == 0:
            cur -= 1
    if cur == 0:
        break
    i = 0
    while i < len(a):
        if ord(a[i]) - 97 == cur:
            if i == 0:
                if ord(a[i]) - ord(a[i+1]) == 1:
                    del a[i]
                    mark[cur] -= 1
                else:
                    i += 1
            elif i == len(a) - 1:
                if ord(a[i]) - ord(a[i-1]) == 1:
                    mark[cur] -= 1
                    del a[i]
                else:
                    i += 1
            else:
                if ord(a[i]) - ord(a[i-1]) == 1 or ord(a[i]) - ord(a[i+1]) == 1:
                    mark[cur] -= 1
                    del a[i]
                else:
                    i += 1
        else:
            i += 1
    i = len(a) - 1
    while i >= 0 and mark[cur] > 0:
        if ord(a[i]) - 97 == cur:
            mark[cur] -= 1
            if i == 0:
                if ord(a[i]) - ord(a[i+1]) == 1:
                    del a[i]
                else:
                    i -= 1
            elif i == len(a) - 1:
                if ord(a[i]) - ord(a[i-1]) == 1:
                    del a[i]
                else:
                    i -= 1
            else:
                if ord(a[i]) - ord(a[i-1]) == 1 or ord(a[i]) - ord(a[i+1]) == 1:
                    del a[i]
                else:
                    i -= 1
        else:
            i -= 1
        #print(a)
print(n-len(a))

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))

import atexit
import io
import sys
import math
from collections import defaultdict,Counter

# _INPUT_LINES = sys.stdin.read().splitlines()
# input = iter(_INPUT_LINES).__next__
# _OUTPUT_BUFFER = io.StringIO()
# sys.stdout = _OUTPUT_BUFFER

# @atexit.register
# def write():
#     sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

# sys.stdout=open("CP3/output.txt",'w')
# sys.stdin=open("CP3/input.txt",'r')

# m=pow(10,9)+7
n=int(input())
s=list(input())
if n==1:
    print(0)
else:
    # s1=s[:]
    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
                else:
                    if 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))

#------------------------template--------------------------#
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-6
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()]

#-------------------------code---------------------------#
# vsInput()

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)

    # print(s,char,removed,prev)

    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)

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):
            # print(i, j, b[j], b[j-1], b[j] == i and (b[j] == b[j-1] + 1 or b[j] == b[j+1] + 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(idx, b, len(b))

print(n - len(b))

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)):
            # print(s)
            c = chr(ord('a') + ci)
            # print(c)
            prev_c = chr(ord('a') + ci-1)
            # print(prev_c)
            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

    # for ci in reversed(range(26)):
    #   # print(s)
    #   c = chr(ord('a') + ci)
    #   # print(c)
    #   prev_c = chr(ord('a') + ci-1)
    #   # print(prev_c)
    #   new_s = []
    #   for i in range(len(s)):
    #       if s[i] == c:
    #           if len(new_s) > 0 and new_s[-1] == prev_c:
    #               res += 1
    #               continue
    #           if i < (len(s) -1) and s[i+1] == prev_c:
    #               res += 1
    #               continue
    #       new_s.append(s[i])
    #   s = "".join(new_s)
    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)

if __name__ == "__main__":
    solve_test_case(0)

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
        #the forward loop
        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
        #now the backward loop
        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)

import math
from collections import *

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

flag = True

ans = 0

while flag and len(s) > 1:
    flag = False
    for i in range(len(s)):
        if i == 0:
            tst = False
            for j in range(1,len(s)):
                if ord(s[j])-ord(s[i]) == 1:
                    tst = True
                    break
            if tst == False and ord(s[i])-ord(s[i+1]) == 1:
                s = s[1:len(s)]
                flag = True
                ans+=1
                break
        elif i == len(s)-1:
            tst = False
            for j in range(0,len(s)-1):
                if ord(s[j])-ord(s[i]) == 1:
                    tst = True
                    break
            if tst == False and ord(s[i])-ord(s[i-1]) == 1:
                flag = True
                s = s[0:len(s)-1]
                ans+=1
                break
        else:
            tst = False
            for j in range(0,i):
                if ord(s[j])-ord(s[i]) == 1:
                    tst = True
                    break
            for j in range(i+1,len(s)):
                if ord(s[j])-ord(s[i]) == 1:
                    tst = True
                    break
            chk = ord(s[i])-ord(s[i-1]) == 1 or ord(s[i])-ord(s[i+1]) == 1
            if tst == False and chk:
                flag = True
                ans+=1
                s1 = s[0:i]
                s2 = s[i+1:len(s)]
                s = s1+s2
                break

flag = True
while flag and len(s)>1:
    flag = False
    for i in range(len(s)-1,-1,-1):
        if i == 0:
            if ord(s[i])-ord(s[i+1]) == 1:
                ans+=1
                flag = True
                s = s[1:len(s)]
                break
        elif i == len(s)-1:
            if ord(s[i])-ord(s[i-1]) == 1:
                ans+=1
                flag = True
                s = s[0:len(s)-1]
                break
        else:
            if ord(s[i+1])-ord(s[i]) !=1 and ord(s[i-1])-ord(s[i]) !=1:
                if ord(s[i+1])-ord(s[i]) ==-1 or ord(s[i-1])-ord(s[i]) ==-1:
                    flag = True
                    ans+=1
                    s1 = s[0:i]
                    s2 = s[i+1:len(s)]
                    s = s1+s2
                    break
print(ans)

from sys import stdin
from collections import deque
mod = 10**9 + 7
import sys
import random
# sys.setrecursionlimit(10**6)
from queue import PriorityQueue
# def rl():
#     return [int(w) for w in stdin.readline().split()]
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt,factorial,gcd,log2,inf,ceil
# map(int,input().split())
# # l = list(map(int,input().split()))
# from itertools import permutations
import heapq
# input = lambda: sys.stdin.readline().rstrip()
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(x, y):
#     return f(x) // (f(y) * f(x - y))
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())
#
# l1 = list(map(int,input().split()))
#
# l2 = list(map(int,input().split()))
#
# cnt1 = 0
# cnt2 = 0
#
# for i in range(n):
#     if l1[i]>l2[i]:
#         cnt1+=1
#     elif l1[i]<l2[i]:
#         cnt2+=1
# if cnt1>cnt2:
#     print(1)
# elif cnt2>cnt1 and cnt1!=0:
#     z = 1 + ceil((cnt2-cnt1)/cnt1)
#     # print(cnt1,cnt2)
#     if z*cnt1>cnt2:
#         print(z)
#     else:
#         print(z+1)
#
# else:
#     print(-1)

n = int(input())

s = list(input())

hash = defaultdict(bool)
ans = 0
for i in range(123,96,-1):

    z = chr(i)
    # print(z)
    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)

n=input()
n1=n
s=raw_input().strip()
s=[ord(i) for i in s]
i=122
while i>=97:
    f=1
    while f:
        f1=0
        for j in range(n):
            if s[j]==i and ( (j>0 and s[j]-s[j-1]==1) or (j<n-1 and s[j]-s[j+1]==1)):
                f1=1
                s=s[:j]+s[j+1:]
                n=len(s)
                break
        if not f1:
            f=0
            i-=1
print n1-n

import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

if __name__ == '__main__':
    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):
                #print(toremove,ord(word[i]))
                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)
                    else:
                        if 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(word)
            #print(toremove,word)
    print(res)

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
		# print(l)
		# print(idx)
		l.pop(idx)
# print(l)
print(n-len(l))

n=int(raw_input())
s=raw_input()
cnt=0

while len(s)>1:
	mx,pos=0,-1
	for i in xrange(len(s)):
		if i==0 and len(s)>1:
			if s[0]==chr(ord(s[1])+1):
				if s[0]>mx: mx,pos=s[0],0
		elif i==len(s)-1:
			if s[i]==chr(ord(s[i-1])+1):
				if s[i]>mx: mx,pos=s[i],i
		else:
			if s[i]==chr(ord(s[i-1])+1):
				if s[i]>mx: mx,pos=s[i],i
			elif s[i]==chr(ord(s[i+1])+1):
				if s[i]>mx: mx,pos=s[i],i
	if pos==-1:
		break
	else:
		s=s[:pos]+s[(pos+1):]
	cnt+=1

print cnt

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=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)

n = int(input())
u = list(input())
lft = list(range(-1, n))
rht = list(range(1, n)) + [-1]
d = []
for i in range(97, 97 + 26):
    d.append(chr(i))
d.reverse()
ans = 0
for k in range(len(d) - 1):
    for j in range(n):
        for i in range(n):
            if u[i] != d[k]:
                continue
            i1 = lft[i]
            j1 = rht[i]
            if i1 != -1 and u[i1] == d[k + 1] or\
               j1 != -1 and u[j1] == d[k + 1]:
                u[i] = -1
                ans += 1
                if lft[i] != -1 and rht[i] != -1:
                    rht[lft[i]], lft[rht[i]] = rht[i], lft[i]
                elif lft[i] != -1:
                    rht[lft[i]] = rht[i]
                elif rht[i] != -1:
                    lft[rht[i]] = lft[i]
##        print(*u, "****", d[k])
##        print(*lft)
##        print(*rht)
##        print()

print(ans)

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 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))

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

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):
        count+=1
print(count)

from sys import stdin, stdout

n = int(stdin.readline())
s = stdin.readline()

alphabet = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's','r', 'q', 'p','o', 'n',
            'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a']

for c in range(25):
    i = 0
    while i < len(s):
        if len(s) == 1:
            break
        if s[i] == alphabet[c]:
            if i == 0:
                if s[1] == alphabet[c+1]:
                    s = s[1:]
                    i-= 1
            elif i == len(s) - 1:
                if s[-2] == alphabet[c+1]:
                    s = s[:i]
                    i -= 1
            elif s[i-1] == alphabet[c+1] or s[i+1] == alphabet[c+1]:
                s = s[:i] + s[i+1:]
                i -= 1
        i += 1

s = s.strip()

stdout.write(str(n - len(s)))

import math
#q=int(input())
q=1
for _ in range(q):
    n=int(input())
    #a,b=map(int,input().split())
    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
    #print(a)
    ans=0
    #print(chr(1+97))
    for i in range(25,0,-1):
        if a[i]==1:
            while(b[i]>0):
                for j in range(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
                            break
                        elif j<len(l)-1 and l[j+1]==chr(i+96):
                            l.pop(j)
                            ans+=1
                            b[i]-=1
                            break
                        else:
                            b[i]=0
                            break
    print(ans)

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

    print(ans)

main()

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:
                    j -= 1
                a = list(filter(lambda x: x != '', a))
            j += 1

print(n - len(a))

import sys
import copy
input=sys.stdin.readline
from math import *
n=int(input())
s=list(input().rstrip())
p=copy.deepcopy(s)
c1=0
j=n-1
for i in range(n):
    j=len(s)-1
    while j>0:
        if ord(s[j])-ord(s[j-1])==1:
            s.pop(j)
            c1+=1
        j-=1
for i in range(n):
    j=0
    while j<len(s)-1:
        if ord(s[j])-ord(s[j+1])==1:
            s.pop(j)
            c1+=1
        else:
            j+=1
#print(s,c1)
j=0
s=p
c2=0
#print(s)
for i in range(n):
    j=0
    while j<len(s)-1:
        if ord(s[j])-ord(s[j+1])==1:
            s.pop(j)
            c2+=1
        else:
            j+=1
for i in range(n):
    j=len(s)-1
    while j>0:
        if ord(s[j])-ord(s[j-1])==1:
            s.pop(j)
            c2+=1
        j-=1
#print(s,c2)
print(max(c1,c2))

def corr(rng):
    for j in rng:
        if s[j] < s[i]:
            return s[j] == s[i] - 1
    return False

ans = 0
n = int(input())
s = tuple(map(ord, input()))
for i in range(n):
    if corr(range(i, -1, -1)) or corr(range(i, n)):
        ans += 1
print(ans)

''' Remove Adjacent
'''

def pc(c):
    return chr(ord(c) - 1)

''' routine '''

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)

#print(azindex.items())
change = True
while change:
    change = False
    for letter, indices in azindex.items():
        if len(indices) == 0 or letter == 'a':
            continue
        # print('letter', letter, list(azindex.items())[-3:])
        possible = -1
        for index in indices:
            if string[max(index - 1, 0)] == pc(letter) or string[min(index + 1, len(string) - 1)] == pc(letter):
                # print(index, string)
                string = string[:index] + string[index+1:]
                possible = index
                change = True
                removalcount += 1

                break
        # print(possible)
        if possible > -1:

            for letter in azindex.keys():
                newindices = []
                indices = azindex[letter]
                # if letter < 'd': print(letter, indices)
                for index in indices:
                    if index > possible:
                        newindices.append(index - 1)
                    elif index < possible:
                        newindices.append(index)
                azindex[letter] = newindices

print(removalcount)

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

#########################
# imgur.com/Pkt7iIf.png #
#########################

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)

# region fastio

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]:
                #print(alph[ord(i)-97-1])
                s.pop(j)
                #print(s)
            else:
                j+=1
        else:
            j+=1
print(n-len(s)+2)

n = 6
s = "abbbbb"

l = []
for i in range(n):
	l.append(ord(s[i]))

c = 0

while len(l) > 1:
	m = max(l)
	i = 0
	while l[i] != m:
		i += 1
	if i == 0:
		if l[i] - l[i + 1] == 1:
			l.pop(i)
			c += 1
	elif i == len(l) - 1:
		if l[i] - l[i - 1] == 1:
			l.pop(i)
			c += 1
	elif l[i] - l[i - 1] == 1 or l[i] - l[i + 1] == 1:
		l.pop(i)
		c += 1

print(c)

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

def calc(s):
    mn = mx = ord(s[0])
    ns = ""
    for ch in s:
        if mn < ord(ch) and ord(ch) <= mx+1:
            mx = ord(ch)
        else:
            ns += ch
            mn = mx = ord(ch)
    return ns

s = calc(s)
#print(s)
s = calc(s[::-1])
#print(s)
print(n-len(s))

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])
            else:
                if(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)
#

n = int(input())
s = [ord(i) for i in input()]
s.append(0)
s1 = []
p = s[0]
c = 1
for i in range(1,n+1):
    if s[i]!=s[i-1]:
        s1.append([p,c])
        p = s[i]
        c = 1
    else:
        c += 1

out = 0
while True:
    l = len(s1)
    temp = [1]*l
    for i in range(l):
        if (i>0 and s1[i][0]-s1[i-1][0]==1) or (i<l-1 and s1[i][0]-s1[i+1][0]==1):
            out+=s1[i][1]
            temp[i]=0
    if sum(temp)==l:
        break
    s1 = [s1[i] for i in range(l) if temp[i]]
print(out)

n = int(input())
S = list(input())
alphabet = 'abcdefghijklmnopqrstuvwxyz'
newS = []
i = 0
ans = 0
while i < n:
    candelete = 0
    j = 1
    if i + j < n and ord(S[i + j]) - ord(S[i + j - 1]) == 1:
        while j + i < n:
            if 1 >= ord(S[i + j]) - ord(S[i + j - 1]) >= 0:
                j += 1
                candelete += 1
            else:
                break
    newS.append(S[i])
    ans += candelete
    i += candelete
    i += 1
i = 0
S = newS
n = len(S)
while i < n:
    candelete = 0
    j = -1
    if i + j > -1 and ord(S[i + j]) - ord(S[i + j - 1]) == 1:
        while j + i > -1:
            if 1 >= ord(S[i + j]) - ord(S[i + j - 1]) >= 0:
                j -= 1
                candelete += 1
            else:
                break
    ans += candelete
    i += candelete
    i += 1
print(ans)

n=int(input())
s=list(input())
for i in range(ord("z"),ord("a")-1,-1):
    for j in range(0,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)

        elif(j==0):
            if(s[j]==chr(i) and s[j+1]==chr(i-1)):
                k=s.pop(j)

        else:
            if(s[j]==chr(i) and (s[j-1]==chr(i-1) or s[j+1]==chr(i-1))):
                k=s.pop(j)

        #print(chr(i),s,j,len(s))
print(n-len(s))

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) for x in input()]
t = s
t.sort(reverse = True)
count = 0
for i in t:
    if len(s) == 1:
        break
    for j in range(len(s)):
        if s[j] == i:
            if j == 0:
                if abs(s[1]-i)==1:
                    s.pop(j)
                    break
            elif j==len(s)-1:
                if abs(s[len(s)-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))

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

while 1:
    i=0
    f=0

    while i<len(s):
        p=ord(s[i])
        count=0
        st = i
        while i<len(s) and p==ord(s[i]):
            i+=1
            p+=1
            count+=1
        if count>1:
            s = s[:st+1]+s[i:]
            f=1
            break
        else:
            i = st
            count=0
            p=ord(s[i])
            while i<len(s) and p==ord(s[i]):
                i+=1
                p-=1
                count+=1
            if count>1:
                s = s[:st]+s[i-1:]
                f=1
                break

    if f==0:
        break

print(n-len(s))

import atexit
import io
import sys
import math
from collections import defaultdict,Counter

# _INPUT_LINES = sys.stdin.read().splitlines()
# input = iter(_INPUT_LINES).__next__
# _OUTPUT_BUFFER = io.StringIO()
# sys.stdout = _OUTPUT_BUFFER

# @atexit.register
# def write():
#     sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

# sys.stdout=open("CP3/output.txt",'w')
# sys.stdin=open("CP3/input.txt",'r')

# m=pow(10,9)+7
n=int(input())
s=list(input())
if n==1:
    print(0)
else:
    # s1=s[:]
    for j in range(122,97,-1):
        k=0
        while k<len(s) and len(s)>1:
            if s[k]==chr(j):
                if k==0:
                    if s[1]==chr(j-1):
                        del(s[k])
                    else:
                        k+=1
                elif k==len(s)-1:
                    if s[-2]==chr(j-1):
                        del(s[k])
                    else:
                        k+=1
                else:
                    if s[k-1]==chr(j-1) or s[k+1]==chr(j-1):
                        del(s[k])
                    else:
                        k+=1
            else:
                k+=1

    print(n-len(s))

'''
	CodeForces 1321C
	Remove Adjacent

	Tags: Ad-hoc, String Manipulation
'''
import re
from functools import reduce

def iter(s, idx):
	chA = chr(ord('a') + idx - 1)
	chB = chr(ord(chA) + 1)
	pat = re.compile(f'{chA}{chB}+|{chB}+{chA}')
	return re.sub(pat, chA, s)

origin = int(input())
s = reduce(iter, range(25, 0, -1), input().strip())

print(origin - len(s))

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

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):
        count+=1
print(count)

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
	while j < len(s):
		print(s, j)
		if ord(s[j]) == (l[0]):
			if j == 0:
				if ord(s[1]) == l[0] - 1:
					s = s[1:]
					c += 1
				else:
					j += 1
			elif j == len(s) - 1:
				if ord(s[len(s) - 2]) == l[0] - 1:
					s = s[:len(s) - 1]
					c += 1
				else:
					j += 1
			else:
				if ord(s[j + 1]) == l[0] - 1 or ord(s[j - 1]) == l[0] - 1:
					s = s[:j] + s[j + 1:]
					c += 1
				else:
					j += 1
		else:
			j += 1
	l.pop(0)

print(c)

n=int(input())
s=input()[:n]
print(s)
a=[x for x in s]
for j in range(25,0,-1):
	for k in range(n):
		ans=[]
		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))

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:
                    j -= 1
                a = list(filter(lambda x: x != '', a))
            j += 1

print(n - len(a))

import sys
import copy
input=sys.stdin.readline
from math import *
n=int(input())
s=list(input().rstrip())
p=copy.deepcopy(s)
c1=0
j=n-1
for i in range(n):
    j=len(s)-1
    while j>0:
        if ord(s[j])-ord(s[j-1])==1:
            s.pop(j)
            c1+=1
        j-=1
for i in range(n):
    while j<len(s)-1:
        if ord(s[j])-ord(s[j+1])==1:
            s.pop(j)
            c1+=1
        else:
            j+=1
#print(s,c1)
j=0
s=p
c2=0
#print(s)
for i in range(n):
    while j<len(s)-1:
        if ord(s[j])-ord(s[j+1])==1:
            s.pop(j)
            c2+=1
        else:
            j+=1
for i in range(n):
    j=len(s)-1
    while j>0:
        if ord(s[j])-ord(s[j-1])==1:
            s.pop(j)
            c2+=1
        j-=1
#print(s,c2)
print(max(c1,c2))

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

import sys
input = sys.stdin.readline

n = int(input())
s = input().strip()
ans = 0
while True:
    ansn = ans
    for i in xrange(25):
        new_s = ''
        for j in xrange(len(s)):
            if s[j] == chr(122-i) and ((j>0 and s[j-1] == chr(122-i-1)) or (j<len(s)-1 and s[j+1]  == chr(122-i-1))):
                ans += 1
            else:
                new_s += s[j]
        s = new_s
    if ansn == ans:
        break
print(ans)

n = int(input())
u = list(input())
lft = list(range(-1, n))
rht = list(range(1, n)) + [-1]
d = []
for i in range(97, 97 + 26):
    d.append(chr(i))
d.reverse()
ans = 0
for k in range(len(d) - 1):
    for i in range(n):
        if u[i] == -1 or u[i] != d[k]:
            continue
        i1 = lft[i]
        j1 = rht[i]
        if i1 != -1 and u[i1] == d[k + 1] or\
           j1 != -1 and u[j1] == d[k + 1]:
            u[i] = -1
            ans += 1
            if lft[i] != -1 and rht[i] != -1:
                rht[lft[i]], lft[rht[i]] = rht[i], lft[i]
            elif lft[i] != -1:
                rht[lft[i]] = rht[i]
            elif rht[i] != -1:
                lft[rht[i]] = lft[i]
##        print(*u, "****", d[k])
##        print(*lft)
##        print(*rht)
##        print()

print(ans)

def solve_test_case(t):
    n = int(input())
    s = str(input())

    res = 0

    for ci in reversed(range(26)):
    	# print(s)
    	c = chr(ord('a') + ci)
    	# print(c)
    	prev_c = chr(ord('a') + ci-1)
    	# print(prev_c)
    	new_s = []
    	for i in range(len(s)):
    		if s[i] == c:
    			if len(new_s) > 0 and new_s[-1] == prev_c:
    				res += 1
    				continue
    			if i < (len(s) -1) and s[i+1] == prev_c:
    				res += 1
    				continue
    		new_s.append(s[i])
    	s = "".join(new_s)
    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)

if __name__ == "__main__":
    solve_test_case(0)

s=int(input())
st=input()
fc=0
ti=0
fi=0
A=[0 for i in range(s)]
for i in range(s):
    flag=0
    if (i!=(s-1) and ord(st[i])==(ord(st[i+1])+1)):
        ti=max(i-1,0)
        fi=i
        flag=1
        fc=fc+1
        A[i]=1
        #print("1",st[i],ti,fi)

    elif(ord(st[i])==(ord(st[i-1])+1)):
        ti=max(i-1,0)
        fi=i
        flag=1
        fc=fc+1
        A[i]=1
        #print("2",st[i],ti,fi)

    else:
        for j in range(ti,fi):
            if(ord(st[j])==(ord(st[i])-1) and A[i]!=1):
                fc=fc+1
                fi=min(fi+1,s-1)
                A[i]=1
                #print("3",st[i],ti,fi)
                flag=1

            elif(ord(st[j])==(ord(st[i])+1) and A[j]!=1):
                fc=fc+1
                if(ord(st[max(j-1,0)])==(ord(st[i])-1) and A[i]!=1):
                    fc=fc+1
                    fi=i
                    ti=i
                    A[i]=1
                    #print("4",st[i],ti,fi)

                A[j]=1
                #print("5",st[j],ti,fi)

    #print(i)
    if(flag==0):
        ti=i
        fi=i

print(fc)

n = int(input())
c = input()
s = [0] * n
for i in range(n):
    s[i] = [c[i], 0]
for i in range(26):
    a = chr(ord('z') - i)
    flag = True
    while flag:
        j = 0
        while j < len(s) and (s[j][0] != a or s[j][1] == 1):
            j += 1
        if j == len(s):
            flag = False
        else:
            s[j][1] = 1
            if j > 0 and s[j - 1][0] == chr(ord(a) - 1) or j < len(s) - 1 and s[j + 1][0] == chr(ord(a) - 1):
                s.pop(j)
print(n - len(s))

import sys
# from math
import bisect
import heapq
# from collections import deque

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

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)):
        # print(i)
        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:
            maxx = ord(s[i])
            maxxind = i
            flag = True
    if flag :
        s = s[0:maxxind] + s[maxxind+1:]
        cnt+=1
print(cnt)

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:
        # Check first
        if seq[0] - seq[1] == 1:
            candidates.append(0)
        # Check others
        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)
        # Check last
        if seq[-1] - seq[-2] == 1:
            candidates.append(len(seq) - 1)
        #print(seq, candidates)

        if len(candidates) > 0:
            # Use priority
            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:]
            print(seq_to_str(new_seq), to_del_index, check1(seq, to_del_index), check2(seq, to_del_index), check3(seq, to_del_index))
            ans += 1
            make_move(new_seq)

_ = int(input())
seq = [ord(s) - ord('a') for s in input()]
make_move(seq)
print(ans)

n,cnt=int(raw_input()),0
s=raw_input()

while len(s)>1:
	mx,pos=0,-1
	for i in xrange(len(s)):
		if i>0:
			if s[0]==chr(ord(s[i-1])+1):
				if s[i]>mx: mx,pos=s[i],0
		if i<len(s)-1:
			if s[i]==chr(ord(s[i+1])+1):
				if s[i]>mx: mx,pos=s[i],i
	if pos==-1: break
	else: s=s[:pos]+s[(pos+1):]
	cnt+=1

print cnt

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

n = 6
s = "bbbbba"

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]):
			print(s)
			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
			else:
				if 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

I = lambda: int(input())
readline = lambda: sys.stdin.readline().strip('\n')
RM = readmap  = lambda x=int: map(x,readline().split(' '))

#1321 625 div2
#C: Remove Adjacent
n,s = I(),readline()
for i in range(25,0,-1):
    y = chr(ord('a')+i)
    x = chr(ord('a')+i-1)
    s = s.replace(x+y,x).replace(y+x,x)
print(n-len(s))
quit()
#B:Journey Planning
#overkill approach: dynamic programming; TLE
#pmax0 = 0
#bmax = b.copy()
#for i in range(n-1,-1,-1):
#    if max0<b[i]:
#        max0 = max(max0,b[i])
#        continue
#    bmax[i] += max([0]+[bmax[j] for j in range(i+1,n) if j-i == b[j]-b[i]])
#    max0 = max(max0,b[i])
#print(max(bmax))

#**trick: find common features in the sequence in O(1)**
d = {}
for i,x in zip(range(I()),RM()):
    d[x-i] = d.get(x-i,0) + x
print(max(d.values()))
quit()
#A: contest for robots
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)

from math import *
alf = list(reversed('abcdefghijklmnopqrstuvwxyx'))
def adj(a, b):
    return chr(ord(a) - 1) == b

n = int(input())
s = [i for i in input()]
for j in range(n*2):
    for a in alf:
        i = 0
        while i < len(s):
            if i > 0 and adj(s[i], s[i-1]):
                s.pop(i)
            elif i < len(s) - 1 and adj(s[i], s[i+1]):
                s.pop(i)
            else:
                i += 1

print(n - len(s))

n = int(input())
s = input()
if n == 1:
    print(0)
else:
    alph = "abcdefghijklmnopqrstuvwxyz"
    f = True
    while f:
        cnt = 0
        for i in range(len(alph) - 1, 0, -1):
            if len(s) == 1:
                break
            for j in range(len(s) - 1, -1, -1):
                if len(s) == 1:
                    break
                if s[j] == alph[i]:
                    if j != 0 and j != len(s) - 1:
                        if s[j - 1] == alph[i - 1] or s[j + 1] == alph[i - 1]:
                            s = s[:j] + s[j + 1:]
                            cnt += 1
                    elif j == 0:
                        if s[j + 1] == alph[i - 1]:
                            s = s[:j] + s[j + 1:]
                            cnt += 1
                    else:
                        if s[j - 1] == alph[i - 1]:
                            s = s[:j] + s[j + 1:]
                            cnt += 1
        if cnt == 0:
            f = False
    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 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
                    y=y[:len(y)-1-j]+y[len(y)-j:]
                else:
                    cont=False
            else:
                cont=False
print(ans)

n=int(input());s=input();S=[];S.extend(s);ind=[];S1=S.copy()
for i in range(n):ind.append([S[i],i+1])
ind.sort(reverse=True);S=['}']+S+['}'];m=0;Ans=0
for i in ind:
    t=i[1]
    if ord(S[t-1])+1==ord(S[t]) or ord(S[t+1])+1==ord(S[t]):
        del(S[t])
        for j in ind:
            if j[1]>t:j[1]-=1
while True:
    t=S1.index(max(S1))
    if len(S1)<2:break
    if t==0 and ord(S1[0])==ord(S1[1])+1:del(S1[0])
    elif t==len(S1)-1 and ord(S1[t])==ord(S1[t-1])+1:del(S1[t])
    elif ord(S1[t])==ord(S1[t-1])+1 or ord(S1[t])==ord(S1[t+1])+1:del(S1[t])
    else:m+=1
    Ans+=1
    if m>n:break
print(max(Ans,n-len(S)+S.count('}')))

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

# def compute(s):
# 	global dp
# 	if len(s)==1:
# 		return 0
# 	elif len(s) in dp and s in dp[len(s)]:
# 		return dp[len(s)][s]
# 	else:
# 		ans = -1
# 		for i in range(len(s)):
# 			if (i!=0 and pos[s[i-1]]==pos[s[i]]-1) or (i!=len(s)-1 and pos[s[i+1]]==pos[s[i]]-1):
# 				new_s = s[:i]+s[i+1:]
# 				val = compute(new_s)
# 				if val > ans:
# 					ans = val
# 		if len(s) in dp:
# 			dp[len(s)][s]=ans+1
# 		else:
# 			dp[len(s)]={s:ans+1}
# 		return ans+1

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]==char:
			if (i!=0 and pos[s[i-1]]==pos[s[i]]-1) or (i!=len(s)-1 and pos[s[i+1]]==pos[s[i]]-1):
				ans+=1
			else:
				ans+=compute(word,n-1)
				word=""
		else:
			word+=s[i]
	ans+=compute(word,n-1)
	return ans

input()
print(compute(input(),25))
# print(dp)

#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__

def main():
    n = int(input())
    s = list(input())
    for _ in range(200):
        for i in reversed(range(26)):
            a, b = chr(i + 96), chr(i + 97)
            j = 0
            while j < len(s) and len(s) > 1:
                if j == 0:
                    if s[j] == b and s[j + 1] == a:
                        s.pop(j)
                    else:
                        j += 1
                elif j < len(s) - 1:
                    if s[j] == b and (s[j + 1] == a or s[j - 1] == a):
                        s.pop(j)
                    else:
                        j += 1
                elif j == len(s) - 1:
                    if s[j] == b and s[j - 1] == a:
                        s.pop(j)
                    else:
                        j += 1
                else:
                    j += 1
    print(n - len(s))

# region fastio

BUFSIZE = 8192

class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    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("\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 FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()

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()

sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

n = int(input())
S = list(input())
alphabet = 'abcdefghijklmnopqrstuvwxyz'
newS = []
i = 0
ans = 0
while i < n:
    candelete = 0
    j = 1
    while j + i < n:
        if 1 >= ord(S[i + j]) - ord(S[i + j - 1]) >= 0:
            j += 1
            candelete += 1
        else:
            break
    newS.append(S[i])
    ans += candelete
    i += candelete
    i += 1
i = 0
S = newS
n = len(S)
while i < n:
    candelete = 0
    j = -1
    while j + i > -1:
        if 1 >= ord(S[i + j]) - ord(S[i + j - 1]) >= 0:
            j -= 1
            candelete += 1
        else:
            break
    ans += candelete
    i += candelete
    i += 1
print(ans)

n = int(input())
s = [ord(i) for i in input()]
s.append(0)
s1 = []
p = s[0]
c = 1
for i in range(1,n+1):
    if s[i]!=s[i-1]:
        s1.append([p,c])
        p = s[i]
        c = 1
    else:
        c += 1

out = 0
while True:
    l = len(s1)
    temp = [1]*l
    for i in range(l):
        if (i>0 and s1[i][0]-s1[i-1][0]==1) or (i<l-1 and s1[i][0]-s1[i+1][0]==1):
            out+=s1[i][1]
            temp[i]=0
    if sum(temp)==l:
        break
    s1 = [s1[i] for i in range(l) if temp[i]]
print(out)

import sys
import copy
input=sys.stdin.readline
from math import *
n=int(input())
s=list(input().rstrip())
p=copy.deepcopy(s)
c1=0
j=n-1
if len(s)==1:
    print(0)
    exit(0)
while 1:
    for i in range(n):
        j=len(s)-1
        while j>0:
            if ord(s[j])-ord(s[j-1])==1:
                s.pop(j)
                c1+=1
            j-=1
    p1=len(s)
    #print(s,1,1)
    for i in range(n):
        j=0
        while j<len(s)-1:
            if ord(s[j])-ord(s[j+1])==1:
                s.pop(j)
                c1+=1
            else:
                j+=1
    p2=len(s)
    #print(s,1,2)
    if p1==p2:
        break
#print(s,c1)
j=0
s=p
c2=0
#print(s)
while 1:
    for i in range(n):
        j=0
        while j<len(s)-1:
            if ord(s[j])-ord(s[j+1])==1:
                s.pop(j)
                c2+=1
            else:
                j+=1
            if len(s)==1:
                break
    p1=len(s)
    #print(s,2,1)
    for i in range(n):
        j=len(s)-1
        while j>0:
            if ord(s[j])-ord(s[j-1])==1:
                s.pop(j)
                c2+=1
            j-=1
    #print(s,2,2)
    if p1==len(s):
        break
#print(s,c2)
print(max(c1,c2))

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

dp=[[[0,""] for i in range(n)] for i in range(n)]

def collapse(leftString,rightString):
    if len(leftString)==0 or len(rightString)==0:
       return [0,leftString+rightString]

    else:
        p1 = len(leftString)-1
        p2 = 0

        count = 0
        while(p1>=0 and p2<len(rightString)):
            if ord(leftString[p1])-ord(rightString[p2])==1:
                #leftWaala hatega
                p1=p1-1
                count+=1
                continue
            if ord(leftString[p1])-ord(rightString[p2])==-1:
                p2=p2+1
                count+=1
                continue
            break

    finalString = leftString[:p1+1] + rightString[p2:]
    #print(finalString)
    return [count,finalString]

for start in range(0,n):
    dp[start][start][0]=0
    dp[start][start][1]=s[start]

for diff in range(2,n+1):
    for start in range(0,n-diff+1):
        end = start + diff - 1
        dp[start][end][1]= s[start:end+1]

#print(dp)

for diff in range(2,n+1):
    #startIndex
    for start in range(0,n-diff+1):
        end = start + diff - 1
        for k in range(start,end+1):
            prev=-1
            if k-1>=0:
                if ord(s[k])-ord(s[k-1])==1:
                    prev=1
            if k+1<n:
                if ord(s[k])-ord(s[k+1])==1:
                    prev=1
            if prev==-1:
                continue
            leftNumber,leftString,rightNumber,rightString=0,"",0,""
            if k-1>=0:
                leftNumber,leftString = dp[start][k-1][0],dp[start][k-1][1]
            if k+1<n:
                rightNumber,rightString= dp[k+1][end][0],dp[k+1][end][1]

            ret = collapse(leftString,rightString)
            #print('-------')
            #print(ret,leftString,rightString,start,end,k,diff)
            #print('-------')
            ans = leftNumber + rightNumber + ret[0] + 1
            if ans>dp[start][end][0]:
                dp[start][end][0]=ans
                dp[start][end][1]=ret[1]

print(dp[0][len(s)-1][0])

from sys import stdin
inf=stdin
#inf=open("data1.txt",'rt')

n=int(inf.readline())
s=inf.readline()
s=s[:n]

changed=False
while not changed:
#	print("dec",s)
	changed=True
	i=0
	ll=len(s)
	found=False
	while(i+1<ll and ord(s[i])!=ord(s[i+1])+1):
		i+=1
	j=i
	while(j+1<ll and ord(s[j])==ord(s[j+1])+1):
		j+=1
		found=True

	if(found):
		s=s[:i]+s[j:]
		changed=False

#	print("inc",s)
	i=0
	ll=len(s)
	found=False
	while(i+1<ll and ord(s[i])!=ord(s[i+1])-1):
		i+=1
	j=i
	while(j+1<ll and ord(s[j])==ord(s[j+1])-1):
		j+=1
		found=True

	if(found):
		s=s[:i+1]+s[j+1:]
		changed=False

print(n-len(s))
# for i in dicti:
# 	temp=0
# 	for j in helper:
# 		if(j[0]<=i[0] and j[1]<=i[1]):
# 			temp+=(i[0]-j[0]+1)*(i[1]-j[1]+1)
# 		if(j[1]<=i[0] and j[0]<=i[1] and j[0]!=j[1]):
# 			temp+=(i[0]-j[1]+1)*(i[1]-j[0]+1)
# 	count+=temp*dicti[i]

# def all_partitions(string):
#     for cutpoints in range(1 << (len(string)-1)):
#         result = []
#         lastcut = 0
#         for i in range(len(string)-1):
#             if (1<<i) & cutpoints != 0:
#                 result.append(string[lastcut:(i+1)])
#                 lastcut = i+1
#         result.append(string[lastcut:])
#         yield result

# maxyet=0
# store={'h': -6, 'e': -7, 'l': -8, 'o': 3, 'he': 3, 'hel': -3, 'el': 0, 'hell': 6, 'ell': -5, 'll': 10, 'hello': -3, 'ello': -8, 'llo': 9, 'lo': -6}

# def quality(stri):
# 	return store[stri]

# for partition in all_partitions("hel"):
#     temp=0
#     for i in partition:
#     	temp+=quality(i)
#     if(temp>maxyet):
#     	print(partition)
#     	maxyet=temp

# print(maxyet)

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

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

n = int(input())
str = input()
lst = list(str)

for i in range(122, 97, -1):
    l = len(lst)
    tmp = []
    bul = False
    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
    if bul == True:
        l = len(tmp)
        tmp.reverse()
        for j in tmp:
            del lst[j]
        i = i+1

print(n-len(lst))

import sys
input = sys.stdin.readline
n = int(input())
s = [*map(ord, input().rstrip())]
v = [(x, i) for i, x in enumerate(s)]

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(i)
        v = [(x, i) for i, x in enumerate(s)]
        i = len(s) - 1
        ans += 1
    else:
        i -= 1
print(ans)

n = int(input())
S = list(input())
alphabet = 'abcdefghijklmnopqrstuvwxyz'
ans = 0
newS = []
i = 0
for __ in range(1000):
    while i < n:
        candelete = 0
        j = 1
        if i + j < n and ord(S[i + j]) - ord(S[i + j - 1]) == 1:
            while j + i < n:
                if 1 >= ord(S[i + j]) - ord(S[i + j - 1]) >= 0:
                    j += 1
                    candelete += 1
                else:
                    break
        newS.append(S[i])
        ans += candelete
        i += candelete
        i += 1
    S = newS.copy()
    n = len(S)
    i = n - 1
    newS = []
    while i > -1:
        candelete = 0
        j = -1
        if i + j > -1 and ord(S[i + j]) - ord(S[i + j + 1]) == 1:
            while j + i > -1:
                if 1 >= ord(S[i + j]) - ord(S[i + j + 1]) >= 0:
                    j -= 1
                    candelete += 1
                else:
                    break
        newS.append(S[i])
        ans += candelete
        i -= candelete
        i -= 1
    S = newS.copy()
    n = len(S)
    newS = []
    i = 0
print(ans)

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=[]
		else:
			word.append(s[i])
	ans+=compute(word,n-1)
	# print(s,end=":")
	# print(ans)
	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 = int(input())
c = input()
s = [0] * n
for i in range(n):
    s[i] = [c[i], 0]
for i in range(26):
    a = chr(ord('z') - i)
    flag = True
    while flag:
        j = 0
        while j < len(s) and (s[j][0] != a or s[j][1] == 1):
            j += 1
        if j == len(s):
            flag = False
        else:
            s[j][1] = 1
            if j > 0 and s[j - 1][0] == chr(ord(a) - 1) or j < len(s) - 1 and s[j + 1][0] == chr(ord(a) - 1):
                s.pop(j)
print(n - len(s))

import sys
from array import array  # noqa: F401
from typing import List, Tuple, TypeVar, Generic, Sequence, Union  # noqa: F401

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
    for cc in range(122, 96, -1):
        i = 1
        while i + 1 < len(a):
            if a[i][0] == cc and (a[i - 1][0] == cc - 1 or a[i + 1][0] == cc - 1):
                ans += a[i][1]
                a.pop(i)
            else:
                i += 1

    print(ans)

if __name__ == '__main__':
    main()

n=int(input())
s=input()
num=[]
for i in s:
    num.append(ord(i))
c=0
for m in range(n):
    le=len(num)
    ma=max(num)
    i1=num.index(ma)
    if le<2:
        break
    if i1==0:
        if num[i1+1]==(num[i1]-1):
            c+=1
            num.remove(ma)
        else:
            num[i1]=0
    elif i1==(le-1):
        if num[i1-1]==(num[i1]-1):
            c+=1
            num.remove(ma)
        else:
            num[i1]=0
    else:
        if num[i1-1]==(num[i1]-1) or num[i1+1]==(num[i1]-1):
            c+=1
            num.remove(ma)
        else:
            num[i1]=0
print(c)

import sys
input = sys.stdin.readline

n = int(input())
s = input().strip()
ans = 0
while True:
    ansn = ans
    for i in xrange(25):
        new_s = ''
        for j in xrange(len(s)):
            if s[j] == chr(122-i) and ((j>0 and s[j-1] == chr(122-i-1)) or (j<len(s)-1 and s[j+1]  == chr(122-i-1))):
                ans += 1
            else:
                new_s += s[j]
        s = new_s
    if ansn == ans:
        break
print(ans)

import sys
import math
read = lambda: list(map(int, sys.stdin.readline().strip().split()))

n = int(input())
s = input()
a = []
for i in range(n):
    a.append(s[i])
mark = [0]*26
for num in a:
    mark[ord(num)-97] += 1
cur = 25
flag = True
while len(a) > 1:
    #print(a)
    if cur > 0 and mark[cur] == 0:
        while mark[cur] == 0:
            cur -= 1
    if cur == 0:
        break
    #print(cur)
    i = 0
    while i < len(a):
        if ord(a[i]) - 97 == cur:
            mark[cur] -= 1
            if i == 0:
                if ord(a[i]) - ord(a[i+1]) == 1:
                    del a[i]
                else:
                    i += 1
            elif i == len(a) - 1:
                if ord(a[i]) - ord(a[i-1]) == 1:
                    del a[i]
                else:
                    i += 1
            else:
                if ord(a[i]) - ord(a[i-1]) == 1 or ord(a[i]) - ord(a[i+1]) == 1:
                    del a[i]
                else:
                    i += 1
        else:
            i += 1

print(n-len(a))

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(y, x+y+x, s)
print(n-len(s))

import sys
# sys.setrecursionlimit(10**6)
from sys import stdin, stdout
import bisect            #c++ upperbound
import math
import heapq
def modinv(n,p):
    return pow(n,p-2,p)
def cin():
    return map(int,sin().split())
def ain():                           #takes array as input
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
import math
def Divisors(n) :
    l = []
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) :
            if (n // i == i) :
                l.append(i)
            else :
                l.append(i)
                l.append(n//i)
    return l

"""*******************************************************"""
def main():
    n=inin()
    s=sin()
    a=list(s)
    x=ord("a")
    ans=0
    for i in range(26):
        y=chr(x+25-i)
        n=len(a)
        for j in range(n):
            if(a[j]==y):
                if(j>0 and (a[j-1]==chr(ord(y)-1) or a[j-1]=="*")):
                    a[j]="*"
                    ans+=1
                elif(j<n-1 and (a[j+1]==chr(ord(y)-1) or a[j+1]=="*")):
                    a[j]="*"
                    ans+=1
        a[:] = (value for value in a if value != "*")
        # print(a)
    print(ans)
######## Python 2 and 3 footer by Pajenegod and c1729

# Note because cf runs old PyPy3 version which doesn't have the sped up
# unicode strings, PyPy3 strings will many times be slower than pypy2.
# There is a way to get around this by using binary strings in PyPy3
# but its syntax is different which makes it kind of a mess to use.

# So on cf, use PyPy2 for best string performance.

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')

# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'

# Read all remaining integers in stdin, type is given by optional argument, this is fast
def readnumbers(zero = 0):
    conv = ord if py2 else lambda x:x
    A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()
    try:
        while True:
            if s[i] >= b'0' [0]:
                numb = 10 * numb + conv(s[i]) - 48
            elif s[i] == b'-' [0]: sign = -1
            elif s[i] != b'\r' [0]:
                A.append(sign*numb)
                numb = zero; sign = 1
            i += 1
    except:pass
    if s and s[-1] >= b'0' [0]:
        A.append(sign*numb)
    return A

if __name__== "__main__":
  main()

import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

if __name__ == '__main__':
    t= int(input())
    word=input()
    res=0
    while True:
        n=len(word)
        toremove=[]

        if n==1:
            break
        for i in range(n):
            #print(toremove,ord(word[i]))
            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)
            else:
                if (ord(word[i])==ord(word[i+1])+1 and ord(word[i])!=ord(word[i-1])-1) or (ord(word[i])==ord(word[i-1])+1 and 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(word)
        #print(toremove,word)
    print(res)

n = int(input())
s = input()
if n == 1:
    print(1)
    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))

# -*- coding: utf-8 -*-
"""
Created on Tue Mar  3 19:29:45 2020

@author: hp
"""

n = int(input())
s = input()
count= 0
lst=[]
for i in s:
    lst.append(ord(i))
for k in range(n):
    for j in range(123,97,-1):
        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)

# Author : raj1307 - Raj Singh
# Date   : 01.03.2020

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 collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
from math import ceil,floor,log,sqrt,factorial
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading
#from itertools import permutations
#Copy 2D list  m = [x[:] for x in mark] .. Avoid Using Deepcopy

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
#mod=998244353
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) : # Check Prime Number or not
    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():

    #for _ in range(ii()):

    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
        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

                elif j==n-1:

                    if abd[s[j-1]]==i-1:
                        del s[j]
                        j-=1
                        n-=1

                else:

                    if abd[s[j+1]]==i-1:
                        del s[j]
                        n-=1
                        j-=1

                    else:

                        if abd[s[j-1]]==i-1:
                            del s[j]
                            j-=1
                            n-=1

            j+=1

    print(x-n)

# region fastio
# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py

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):
    """Prints the values to a stream, or to sys.stdout by default."""
    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")

# endregion

if __name__ == "__main__":
    #read()
    main()
    #dmain()

# Comment Read()

def front(s,b):
	if len(s)==1:
		return s

	if b==1:
		s=s[::-1]
	t=''
	for i in range(len(s)-1):
		#print s[i],s[i+1],ord(s[i])-ord(s[i+1])
		if ord(s[i])-ord(s[i+1])==1:
			pass
		else:
			t+=s[i]

	t+=s[-1]
	if b==1:
		t=t[::-1]
	return t

n=input()
s=raw_input()
l=[-1,n]
while l[-1]!=l[-2]:
	s=front(s,1)
	l.append(len(s))
	s=front(s,0)
	l.append(len(s))
	s=front(s,1)
	l.append(len(s))
print n-l[-1]

n= int(input())
a=list(input());le=n
while(True):
    b=True
    for i in range(le):
        if(i>le-1 or a[i]=='a'):
            break
        cur=a[i];prev=chr(ord(a[i])-1)

        x=i-1 if(i!=0) else 0
        y=i+1 if(i!=(le-1)) else i
        if(a[x]==prev or a[y]==prev):
            a.pop(i)
            le-=1
            b=False
    if(b):
        break
print(n-len(a),*a)

from collections import defaultdict

alpha = 'abcdefghijklmnopqrstuvwxyz'
d = defaultdict(int)
c = 0

for alpha_i in alpha:
    d[alpha_i] = c
    c += 1

n = int(input())
s = input()
l = [d[s[i]] for i in range(n)]
ans = 0

while True:
    if len(l)==1:
        break

    rem = set()

    for i in range(len(l)):
        if i==0:
            if l[i]==l[i+1]+1:
                rem.add(i)
        elif i==len(l)-1:
            if l[i]==l[i-1]+1:
                rem.add(i)
        else:
            if l[i] in [l[i-1]+1, l[i+1]+1]:
                rem.add(i)

    if len(rem)==0:
        break

    ans += len(rem)
    new_l = []

    for i in range(len(l)):
        if i not in rem:
            new_l.append(l[i])

    l = new_l

print(ans)

n = int(input())
s = input()
l = [ord(i) for i in s]
cnt=0
while(len(l)>0):
    mxchar = max(l)
    mxindex = l.index(mxchar)
    if((mxindex-1>=0 and l[mxindex-1]-l[mxindex]==-1) or
       (mxindex+1<n and l[mxindex+1]-l[mxindex]==-1)):
        l.remove(mxchar)
        cnt+=1
        n-=1
    else:
        l.remove(mxchar)
        n-=1
print(cnt)

n=int(input())
S=["#"]+list(input())+["#"]

ANS=0
for i in range(25,-1,-1):
    for j in range(n):
        while 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)
print(ANS)

from math import *
alf = list(reversed('abcdefghijklmnopqrstuvwxyx'))
def adj(a, b):
    return chr(ord(a) - 1) == b

n = int(input())
s = [i for i in input()]
for i in range(n*2):
    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)
            elif s[i] == a and i < len(s) - 1 and adj(s[i], s[i+1]):
                s.pop(i)
            else:
                i += 1

print(n - len(s))

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:]
#				print(s, i)
				count += 1
				break

print(count)

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])

    if (split == 0 or adj(string[split-1], c)) or (split == len(string)-1 or adj(string[split+1], c)):
        with_split = 1 + max_moves(string[:split] + string[split+1:])
    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))

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:
                    j -= 1
                a = list(filter(lambda x: x != '', a))
            j += 1

print(n - len(a))

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 sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
import string

#########################
# imgur.com/Pkt7iIf.png #
#########################

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)

# input = sys.stdin.readline

n = ii()
s = [ord(i) for i in input()]
res = 0
while len(s) > 1:
    n = len(s)
    i = 0
    l = r = 0
    m = 1
    while i < n:
        j = i
        while j < n - 1 and s[j + 1] - s[j] == 1: j += 1
        if j - i > r - l:
            l, r = i, j
            m = 1
        j = i
        while j < n - 1 and s[j + 1] - s[j] == -1: j += 1
        if j - i > r - l:
            l, r = i, j
            m = 0
        i += 1
    if r - l > 0:
        res += r - l
        s = s[:l+m] + s[r+m:]
    else:
        break
print(res)

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

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: # O(n)
        biggest_cand = -1
        remove_id = -1

        for j in range(len(s)):  # O(n)
            c = check_neighbours(s, j)
            if c>=0 and ord(s[c]) > biggest_cand:
                remove_id = c

        if remove_id >= 0:
            s.pop(remove_id)  # O(n)
            removed += 1
        else:
            break

    return removed

len_s = int(input())
s = input()
print(remove_neighbors(s))

# sum = O(n(n+n)) = O(n*2n) = O(2n^2) = O(n^2)

import sys
from collections import defaultdict
# input=sys.stdin.readline
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.remove(c)
                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.remove(c)
                m+=1
                break
        else:
            break
print(m)

n=int(input())
s=input()+'0'
num=[]
co=1
for i in range(n):
    if s[i]==s[i+1]:
        co+=1
    else:
        num.append([ord(s[i]),co])
        co=1
c=0
for m in range(n):
    le=len(num)
    mi=max(num)
    ma=mi[0]
    i1=num.index(mi)
    if le<2:
        break
    if i1==0:
        if num[i1+1][0]==(num[i1][0]-1):
            c+=num[i1][1]
            num.remove(mi)
        else:
            num[i1][0]=0
    elif i1==(le-1):
        if num[i1-1][0]==(num[i1][0]-1):
            c+=num[i1][1]
            num.remove(mi)
        else:
            num[i1][0]=0
    else:
        if num[i1-1][0]==(num[i1][0]-1) or num[i1+1][0]==(num[i1][0]-1):
            c+=num[i1][1]
            num.remove(mi)
        else:
            num[i1][0]=0
print(c)

from math import *
alf = list(reversed('abcdefghijklmnopqrstuvwxyx'))
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)
        elif s[i] == a and i < len(s) - 1 and adj(s[i], s[i+1]):
            s.pop(i)
        else:
            i += 1

print(n - len(s))

import math
from collections import *

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

flag = True

ans = 0

while flag and len(s)>1:
    flag = False
    for i in range(len(s)):
        if i == 0:
            if ord(s[i])-ord(s[i+1]) == 1:
                ans+=1
                flag = True
                s = s[1:len(s)]
                break
        elif i == len(s)-1:
            if ord(s[i])-ord(s[i-1]) == 1:
                ans+=1
                flag = True
                s = s[0:len(s)-1]
                break
        else:
            if ord(s[i+1])-ord(s[i]) !=1 and ord(s[i-1])-ord(s[i]) !=1:
                if ord(s[i+1])-ord(s[i]) ==-1 or ord(s[i-1])-ord(s[i]) ==-1:
                    flag = True
                    ans+=1
                    s1 = s[0:i]
                    s2 = s[i+1:len(s)]
                    s = s1+s2
                    break
print(ans)

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

n = int(input())
s = input()
s = [ord(i) for i in s]
out = 0
while s:
    o1 = 0
    f = 0
    p = s[:]
    for i in range(n-1):
        if abs(s[i]-s[i+1])==1:
            f = 1
            if s[i]<s[i+1]:
                p[i+1] = -1
            else:
                p[i] = -1
            o1 += 1
    out += o1
    snew = [i for i in p if i!=-1]
    if snew == s:
        break
    else:
        s = snew
    n = len(s)
print(out)

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:
            print(s[index])
            s = s[:index] + s[index + 1:]
    print(n - len(s))

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

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])

    if (split != 0 and adj(string[split-1], c)) or (split != len(string)-1 and adj(string[split+1], c)):
        with_split = 1 + max_moves(string[:split] + string[split+1:])
    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))

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
                    y=y[:len(y)-1-j]+y[len(y)-j:]
                else:
                    cont=False
            else:
                cont=False
print(ans)

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
	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
				else:
					j += 1
			elif j == len(s) - 1:
				if ord(s[len(s) - 2]) == l[0] - 1:
					s = s[:len(s) - 1]
					c += 1
				else:
					j += 1
			else:
				if ord(s[j + 1]) == l[0] - 1 or ord(s[j - 1]) == l[0] - 1:
					s = s[:j] + s[j + 1:]
					c += 1
				else:
					j += 1
		else:
			j += 1
	l.pop(0)

print(c)

import math
#q=int(input())
q=1
for _ in range(q):
    n=int(input())
    #a,b=map(int,input().split())
    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
    #print(a)
    ans=0
    #print(chr(1+97))
    for i in range(25,0,-1):
        if a[i]==1:
            while(b[i]>0):
                for j in range(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
                            break
                        elif j<len(l)-1 and l[j+1]==chr(i+96):
                            l.pop(j)
                            ans+=1
                            b[i]-=1
                            break
                        else:
                            b[i]=0
    print(ans)

import sys
input = lambda: sys.stdin.readline().rstrip()
n=int(input())
a=[ord(i)-97 for i in input()]
maxx=0
for i in range(n):
    st1=a[:i]
    st=[]
    for j in range(i,n):
        if not st: st.append(a[j])
        else:
            if a[j]+1==st[-1]:
                st.pop()
                st.append(a[j])
            elif st[-1]+1==a[j]:
                continue
            else:
                st.append(a[j])
    stt=st1[:]+st[:]
    st2=[]
    for j in range(len(st1)):
        if not st2: st2.append(st1[j])
        else:
            if a[j]+1==st2[-1]:
                st2.pop()
                st2.append(st1[j])
            elif st2[-1]+1==st1[j]:
                continue
            else:
                st2.append(st1[j])
    rsst=[]
    rst=[]
    sttt=st2[:]+st[:]
    for j in range(len(stt)):
        if not rst: rst.append(stt[j])
        else:
            if stt[j]+1==rst[-1]:
                rst.pop()
                rst.append(stt[j])
            elif rst[-1]+1==stt[j]:
                continue
            else:
                rst.append(stt[j])
    for j in range(len(sttt)):
        if not rsst: rsst.append(sttt[j])
        else:
            if sttt[j]+1==rsst[-1]:
                rsst.pop()
                rsst.append(sttt[j])
            elif rsst[-1]+1==sttt[j]:
                continue
            else:
                rsst.append(stt[j])
    maxx=max(maxx,n-len(rst),n-len(rsst))
print(maxx)

from math import *
alf = list(reversed('abcdefghijklmnopqrstuvwxyx'))
def adj(a, b):
    return chr(ord(a) - 1) == b

n = int(input())
s = [i for i in input()]
for j in range(n*2):
    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)
            elif s[i] == a and i < len(s) - 1 and adj(s[i], s[i+1]):
                s.pop(i)
            else:
                i += 1

print(n - len(s))