0
点赞
收藏
分享

微信扫一扫

A. Vitaliy and Pie(Codeforces Round #297 (Div. 2) 水题)


A. Vitaliy and Pie



time limit per test



memory limit per test



input



output



n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third room and so on — you can go from the (n - 1)-th room to the n-th room. Thus, you can go to room xonly from room x - 1.

n-th room and Vitaly needs to go there.

x from room x - 1, you need to open the door between the rooms with the corresponding key.

t can open the door of type T if and only if t and T are the same letter, written in different cases. For example, key f can open door F.

n - 1

n.

n, which has a delicious potato pie. Write a program that will help Vitaly find out this number.



Input



n (2 ≤ n ≤ 105) — the number of rooms in the house.

s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one.

s contain lowercase Latin letters — the types of the keys that lie in the corresponding rooms. Thus, each odd position i of the given string s contains a lowercase Latin letter — the type of the key that lies in room number (i + 1) / 2.

i of the given string s contains an uppercase letter — the type of the door that leads from room i / 2 to room i / 2 + 1.



Output



n.



Sample test(s)



input



3 aAbB



output



0



input



4 aBaCaB



output



3



input



5 xYyXzZaZ



output



2













#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#define eps 1e-8

using namespace std;

int main()
{
    int n;
    char str[220010];
    int v[301];
    while(scanf("%d",&n)!=EOF)
    {
        scanf("%s",str);
        memset(v,0,sizeof(v));
        int cnt = 0;
        for(int i=0;str[i]!='\0';i++)
        {
            if(str[i]>='a' && str[i]<='z')
            {
                v[str[i]]++;
            }
            else
            {
                if(v[str[i]+32])
                {
                    v[str[i]+32]--;
                }
                else
                {
                    cnt++;
                }
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}



举报

相关推荐

0 条评论