#include #include int main(int argc, char *argv[]) { #define CASE_BIT ('A' ^ 'a') #define MAX_LENGTH 65536 static char stack[MAX_LENGTH]; FILE *input; int c, top; if (input = fopen("input.txt", "r")) { top = -1; while (isalpha(c = fgetc(input))) { if (top >= 0 && (c ^ CASE_BIT) == stack[top]) { --top; } else { if (++top < MAX_LENGTH) stack[top] = c; else return 1; } } fclose(input); } else return 2; printf("%d\n", top + 1); return 0; }