#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
int main(){
    int N;
    scanf("%d",&N);
    if(N<=0 || N>100){
        printf("Invalid input");
        return 0;
    }
    int upperSum=0,lowerSum=0;
    char ch;
    int count=0;
    while(count<N && scanf(" %c",&ch)==1){
        if(isalpha(ch)){
            if(isupper(ch)){
                upperSum+=ch;
            else{
                lowerSum+=;
            count++;
            }
            }
        }
    }
    if(count<N){
        printf("Invalid input");
        return 0;
    }
    printf("%d",abs(upperSum-lowerSum));
    return 0;
}