#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j;
  int n;
  scanf("%d ", &n);
  int storage[26 + 3];
  memset(storage, 0, sizeof(storage));
  char str[5];
  int ans = 0;
  for (i = 1; i < n; i++) {
    scanf("%2s", str);
    if (str[0] - 'a' != str[1] - 'A') {
      storage[str[0] - 'a']++;
      if (!storage[str[1] - 'A'])
        ans++;
      else
        storage[str[1] - 'A']--;
    }
  }
  printf("%d", ans);
  return 0;
}
