import java.util.Scanner;
public class Main {
private static final int LOWER_CASE = 1;
private static final int UPPER_CASE = -1;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = Integer.parseInt(scanner.nextLine());
String text = scanner.nextLine();
scanner.close();
int curr = LOWER_CASE;
int count = 0;
for (int i = 0; i < text.length(); i++) {
char ch = text.charAt(i);
if (curr == LOWER_CASE && isLower(ch)) {
count += 1;
} else if (curr == UPPER_CASE && !isLower(ch)) {
count += 1;
} else {
count += 2;
if (i != text.length() - 1) {
char next = text.charAt(i + 1);
if (isLower(next) && isLower(ch)) {
curr *= -1;
} else if(!isLower(next) && !isLower(ch)){
curr *= -1;
}
}
}
}
System.out.println(count);
}
private static boolean isLower(char ch) {
return ch >= 'a' && ch <= 'z';
}
}