// Arup Guha
// 8/20/2023
// Solution to COP 3502 Fall 2023 Program 0: Sign of Trouble

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 100000
#define NUMLET 26

int* getFreq(char* str);

int main() {

    // Read in both signs.
    char* old_sign = malloc(sizeof(char)*(MAX+3));
    fgets(old_sign, MAX+2, stdin);
    char* new_sign = malloc(sizeof(char)*(MAX+3));
    fgets(new_sign, MAX+2, stdin);

    // Get frequency arrays.
    int* f1 = getFreq(old_sign);
    int* f2 = getFreq(new_sign);

    int res = 0;

    // Go through each letter.
    for (int i=0; i<NUMLET; i++)

        // If the new sign needs more of this letter, then we add the
        // difference to our answer.
        if (f2[i] > f1[i])
            res += (f2[i]-f1[i]);

    // Ta da!
    printf("%d\n", res);

    // Clean up.
    free(old_sign);
    free(new_sign);
    free(f1);
    free(f2);
    return 0;
}

// Returns a frequency array of the upper case letters in str, ignoring all other letters.
int* getFreq(char* str) {

    // Allocate space for the frequency array - zero it out with calloc.
    int* f_array = calloc(NUMLET, sizeof(int));

    // Store so we don't write ineffienct code, since strlen is O(n).
    int len = strlen(str);

    // Loop through string, only counting uppercase letters.
    for (int i=0; i<len; i++)
        if (str[i] >= 'A' && str[i] <= 'Z')
            f_array[str[i]-'A']++;

    return f_array;
}
