#include <bits/stdc++.h>
using namespace std;
int main() {
  int N = 0;
  cin >> N;
  string A;
  cin >> A;
  int alen = A.length();
  int sum = 0;
  int com = 0;
  for (int i = 0; i < alen - 1; i++) {
    if (A[i + 1] < A[i]) {
      com = A[i] - A[i + 1];
      sum += com;
      A[i + 1] += com;
    }
  }
  cout << sum << endl;
  return 0;
}
