#include <bits/stdc++.h>
using namespace std;
int main() {
  char c[1000001];
  int n;
  cin >> n;
  cin >> c;
  char ch;
  int count = 0;
  int sa[26] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  for (int i = 0; i < 2 * (n - 1); i++) {
    ch = c[i];
    if ((ch <= 'z') && (ch >= 'a')) {
      sa[ch - 'a']++;
    } else if ((ch <= 'Z') && (ch >= 'A')) {
      if (sa[ch - 'A'] == 0) {
        count++;
      } else
        sa[ch - 'A']--;
    }
  }
  cout << count << endl;
  return 0;
}
