#include <bits/stdc++.h>
using namespace std;
int m, A[300];
;
char a, b;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    A[a]++;
    if (A[b + 32] != 0)
      A[b + 32]--;
    else
      m++;
  }
  cout << m;
}
