stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <cmath>



using namespace std;

typedef long long ll;



const int INF = 0x7fffffff;

const int _INF = 0x7fffffff + 1;



int main()

{

    char s[1002];

    int n;

    cin>>n;getchar();

    cin>>s;



    int ans = 0;

    int x = 0;

    for(int i = 0; i < n; i++)

    {

        if(s[i] == 'I')

            x++;

        else if(s[i] == 'D')

            x--;

        if(x >= ans)

            ans = x;

    }

    printf("%d", ans);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.218288594452851x):
#include<stdio.h>

	int main(){

		int n;

		

		scanf("%d",&n);

		char str[n];

		

		scanf("%s",str);

		int counter =0;

		int max = 0;

		for(int j =0 ; j<n ;j++){



			if(str[j]=='I'){

				counter++;

				if(counter>= max){

				max=counter;

				}

			}

			else {

				counter--;

			}

		}

		printf("%d",max);

	

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cmath>

#include <cstring>

#include <algorithm>

#include <vector>

#include <map>

#include <cstdlib>

#include <set>

#include <queue>

using namespace std;



#define X first

#define Y second

#define N 100010

typedef long long ll;

typedef pair<int,int> pii;

const int Mod=1000000007;



const double INF=1e18;



char s[N];



int main()

{

	//freopen("in.in","r",stdin);

	//freopen("out.out","w",stdout);

	

	int n,x=0,ans=0; scanf("%d",&n);

	scanf("%s",s);

	for (int i=0;i<n;i++)

	{

		if (s[i]=='I') x++;

		else x--;

		ans=max(ans,x);

	}

	cout<<ans<<endl;

	return 0;



}


// Faster C++ solution for the same problem (measured speedup: 5.177202520564229x):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

char s[1111];

int i,j,k,n,m,a,b,c,d;

int main(){

	while (scanf("%d",&n)!=EOF){

		scanf("%s",s);

		for (k=i=j=0;i<n;i++){

			if (s[i]=='I') j++;else j--;

			k=max(j,k);

		}

		printf("%d\n",k);

	}

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cmath>

#include <cstring>

#include <algorithm>

#include <vector>

#include <map>

#include <cstdlib>

#include <set>

#include <queue>

using namespace std;



#define X first

#define Y second

#define N 100010

typedef long long ll;

typedef pair<int,int> pii;

const int Mod=1000000007;



const double INF=1e18;



char s[N];



int main()

{

	//freopen("in.in","r",stdin);

	//freopen("out.out","w",stdout);

	

	int n,x=0,ans=0; scanf("%d",&n);

	scanf("%s",s);

	for (int i=0;i<n;i++)

	{

		if (s[i]=='I') x++;

		else x--;

		ans=max(ans,x);

	}

	cout<<ans<<endl;

	return 0;



}


// Faster C++ solution for the same problem (measured speedup: 5.186833404602384x):
#include<stdio.h>

int n;

char s[110];

int main(){

	scanf("%d",&n);

	scanf("%s",s);

	int x=0,max=0;

	for (int i=0;i<n;i++){

		if (s[i]=='D') x--;

		else x++;

		if (x>max) max=x;

	}

	printf("%d\n",max);

}
// Slower C++ solution:
#include<set>

#include<map>

#include<stack>

#include<queue>

#include<deque>

#include<cmath>

#include<cstdio>

#include<cctype>

#include<string>

#include<vector>

#include<cstdlib>

#include<cstring>

#include<sstream>

#include<iostream>

#include<algorithm>

#define MAXN 100

#define pii pair<int,int>



using namespace std;

char s[MAXN+80];

int main()

{

	int x=0,Max=0,n,i;

	scanf("%d",&n);

	getchar();

	fgets(s,108,stdin);

	for(i=0;i<n;i++)

	{

		x+=s[i]=='I';

		x-=s[i]=='D';

		Max=max(x,Max);

	}

	printf("%d",Max);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.161686947772295x):
#include<stdio.h>

int n;

char s[110];

int main(){

	scanf("%d",&n);

	scanf("%s",s);

	int x=0,max=0;

	for (int i=0;i<n;i++){

		if (s[i]=='D') x--;

		else x++;

		if (x>max) max=x;

	}

	printf("%d\n",max);

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cmath>

#include <cstring>

#include <algorithm>

#include <vector>

#include <map>

#include <cstdlib>

#include <set>

#include <queue>

using namespace std;



#define X first

#define Y second

#define N 100010

typedef long long ll;

typedef pair<int,int> pii;

const int Mod=1000000007;



const double INF=1e18;



char s[N];



int main()

{

	//freopen("in.in","r",stdin);

	//freopen("out.out","w",stdout);

	

	int n,x=0,ans=0; scanf("%d",&n);

	scanf("%s",s);

	for (int i=0;i<n;i++)

	{

		if (s[i]=='I') x++;

		else x--;

		ans=max(ans,x);

	}

	cout<<ans<<endl;

	return 0;



}


// Faster C++ solution for the same problem (measured speedup: 5.18696356568393x):
#include <stdio.h>



int main() {

	int n;

	scanf("%d", &n);

	

	char arr[n];

	scanf("%s", &arr);

	

	int x = 0;

	int max = 0;

	for(int i = 0; i < n; i++) {

		if(arr[i] == 'I') {

			x++;

			if(max < x) {

				max = x;

			}

		}

		else if(arr[i] == 'D') {

			x--;

		}

	}

	

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:
#include<set>

#include<map>

#include<stack>

#include<queue>

#include<deque>

#include<cmath>

#include<cstdio>

#include<cctype>

#include<string>

#include<vector>

#include<cstdlib>

#include<cstring>

#include<sstream>

#include<iostream>

#include<algorithm>

#define MAXN 100

#define pii pair<int,int>



using namespace std;

char s[MAXN+80];

int main()

{

	int x=0,Max=0,n,i;

	scanf("%d",&n);

	getchar();

	fgets(s,108,stdin);

	for(i=0;i<n;i++)

	{

		x+=s[i]=='I';

		x-=s[i]=='D';

		Max=max(x,Max);

	}

	printf("%d",Max);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.161816477815642x):
#include <stdio.h>



int main() {

	int n;

	scanf("%d", &n);

	

	char arr[n];

	scanf("%s", &arr);

	

	int x = 0;

	int max = 0;

	for(int i = 0; i < n; i++) {

		if(arr[i] == 'I') {

			x++;

			if(max < x) {

				max = x;

			}

		}

		else if(arr[i] == 'D') {

			x--;

		}

	}

	

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;

#define LL long long



int main()

{

    int x = 0, mx = 0;

    string s;

    int n;

    cin >> n >> s;

    for(int i=0;i<n;i++){

        if(s[i] == 'I') x++;

        else x--;

        mx = max(x, mx);

    }

    cout << mx  << '\n';

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.265114018943799x):
#include <stdio.h>



int main() {

	int n;

	scanf("%d", &n);

	

	char arr[n];

	scanf("%s", &arr);

	

	int x = 0;

	int max = 0;

	for(int i = 0; i < n; i++) {

		if(arr[i] == 'I') {

			x++;

			if(max < x) {

				max = x;

			}

		}

		else if(arr[i] == 'D') {

			x--;

		}

	}

	

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <string>



using namespace std;



int main(){

    

int n;

string s;

cin>>n;

cin>>s;



int x=0,max=0;



for(int i=0; i<s.size();i++){

    

    if(s[i]=='I'){

        

        x++;

        if(x>max){max=x;}

    }else{x--;}

}



cout<<max<<endl;

   

    

}

// Faster C++ solution for the same problem (measured speedup: 5.269503391652138x):
#include <stdio.h>



int main() {

	int n;

	scanf("%d", &n);

	

	char arr[n];

	scanf("%s", &arr);

	

	int x = 0;

	int max = 0;

	for(int i = 0; i < n; i++) {

		if(arr[i] == 'I') {

			x++;

			if(max < x) {

				max = x;

			}

		}

		else if(arr[i] == 'D') {

			x--;

		}

	}

	

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string>

using namespace std;



int main()

{

    int n;

    cin>>n;

    string s;

    cin>>s;

    int i=0;

    int arr[n+1];

    arr[0]=0;

    for(int x=0; x<n; x++){

        if(s.at(x)=='I'){

            i++;

        }

        else{

            i--;

        }

        arr[x+1]=i;

    }

    int ans=0;

    for(int x=0; x<=n;x++){

        if(arr[x]>ans){

            ans=arr[x];

        }

    }

    cout<<ans;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.263669129838081x):
#include <stdio.h>



int main() {

	int n;

	scanf("%d", &n);

	

	char arr[n];

	scanf("%s", &arr);

	

	int x = 0;

	int max = 0;

	for(int i = 0; i < n; i++) {

		if(arr[i] == 'I') {

			x++;

			if(max < x) {

				max = x;

			}

		}

		else if(arr[i] == 'D') {

			x--;

		}

	}

	

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main()

{

	int n,c=0,x=0;

	string ch;

	cin>>n;

	for(int i=0;i<n;i++)

    {

	cin>>ch[i];

    }

	for(int i=0;i<n;i++)

    { 

    	if(ch[i]=='I')

    	{		

		x++;          

    	c=max(c,x);    

        }

		else if(ch[i]=='D')

    	x--;        	

    	else

    	break;

	}

	cout<<c;



}

// Faster C++ solution for the same problem (measured speedup: 5.2151250667722735x):
#include <stdio.h>



int main() {

	int n;

	scanf("%d", &n);

	

	char arr[n];

	scanf("%s", &arr);

	

	int x = 0;

	int max = 0;

	for(int i = 0; i < n; i++) {

		if(arr[i] == 'I') {

			x++;

			if(max < x) {

				max = x;

			}

		}

		else if(arr[i] == 'D') {

			x--;

		}

	}

	

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main(){

	int n=0,count=0,max=0;

	string s;

	cin>>n>>s;

	for(int j=0;j<n;j++){

		if(s[j]=='I')

		   count++;

		else

		   count--;

		if(max<count)

		    max=count;      

	}

	cout<<max;

}

// Faster C++ solution for the same problem (measured speedup: 5.220857932283364x):
#include <stdio.h>



int main() {

	int n;

	scanf("%d", &n);

	

	char arr[n];

	scanf("%s", &arr);

	

	int x = 0;

	int max = 0;

	for(int i = 0; i < n; i++) {

		if(arr[i] == 'I') {

			x++;

			if(max < x) {

				max = x;

			}

		}

		else if(arr[i] == 'D') {

			x--;

		}

	}

	

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:
#include <iostream>



using namespace std;



int main()

{

    int n;

    cin >> n;

    string s;

    cin >> s;

    int x=0 , max=0;

    for (int i=0 ; i<n ; i++){



        if(s[i]=='I'){

            x++;

            if(x>max)

                max=x;

            }else if (s[i]=='D'){

            x--;

            }

    }

    cout << max<< endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.269636418871774x):
#include <stdio.h>



int main() {

	int n;

	scanf("%d", &n);

	

	char arr[n];

	scanf("%s", &arr);

	

	int x = 0;

	int max = 0;

	for(int i = 0; i < n; i++) {

		if(arr[i] == 'I') {

			x++;

			if(max < x) {

				max = x;

			}

		}

		else if(arr[i] == 'D') {

			x--;

		}

	}

	

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 100005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

typedef vector<int> vi;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];

int gcd(int a,int b)

{

    if(b==0){

      return a;

     }

    return gcd(b,a%b);

}

int lcm(int a,int b)

{

    int res=(a*b)/gcd(a,b);

    return res;

}

int po(int a,int b)

{

    int res=1;

    while(b)

    {

        if(b%2!=0)

        {

            res*=a;

            b--;

        }

        else

        {

            a*=a;

            b/=2;

        }

    }

    return res;

}



lln modMul(lln  a, lln b,lln mod){

    lln ans = 0;

    a = a % mod;

    while (b > 0){

        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;

        a = (a%mod * 2%mod) % mod;

        b /= 2;

    }

    return ans % mod;

}

lln powerMod(lln a,lln b,lln mod){

	if(b==0)return 1LL%mod;

	lln x=powerMod( a,b/2,mod );

	x = ( x%mod * x%mod ) % mod;

	if( b%2==1 )x = ( x%mod * a%mod ) % mod;

	return x%mod;

}



int main()

{

   string a;

   int len;

   cin>>len;

   cin>>a;

   int maxi=0;



   int c=0;

   for(int i=0;i<len;i++)

   {

       if(a[i]=='I')

       {

           c++;

           maxi=max(maxi,c);

       }

       else

       {

           c--;

           maxi=max(maxi,c);

       }

   }

   cout<<maxi;



}










// Faster C++ solution for the same problem (measured speedup: 5.220720635054209x):
#include <stdio.h>



int main() {

	int n;

	scanf("%d", &n);

	

	char arr[n];

	scanf("%s", &arr);

	

	int x = 0;

	int max = 0;

	for(int i = 0; i < n; i++) {

		if(arr[i] == 'I') {

			x++;

			if(max < x) {

				max = x;

			}

		}

		else if(arr[i] == 'D') {

			x--;

		}

	}

	

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cmath>

#include <cstring>

#include <algorithm>

#include <vector>

#include <map>

#include <cstdlib>

#include <set>

#include <queue>

using namespace std;



#define X first

#define Y second

#define N 100010

typedef long long ll;

typedef pair<int,int> pii;

const int Mod=1000000007;



const double INF=1e18;



char s[N];



int main()

{

	//freopen("in.in","r",stdin);

	//freopen("out.out","w",stdout);

	

	int n,x=0,ans=0; scanf("%d",&n);

	scanf("%s",s);

	for (int i=0;i<n;i++)

	{

		if (s[i]=='I') x++;

		else x--;

		ans=max(ans,x);

	}

	cout<<ans<<endl;

	return 0;



}


// Faster C++ solution for the same problem (measured speedup: 5.188091333941712x):
#include <stdio.h>



int main(){

	int N, max = 0, x = 0;

	scanf("%d", &N);

	char s[N];

	scanf("%s", s);



	for(int i = 0; s[i] != '\0'; i++){

		if(s[i] == 'I'){

			x ++;

		}else if(s[i] == 'D'){

			x --;

		}if(max < x){

			max = x;

		}

	}

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:
#include<set>

#include<map>

#include<stack>

#include<queue>

#include<deque>

#include<cmath>

#include<cstdio>

#include<cctype>

#include<string>

#include<vector>

#include<cstdlib>

#include<cstring>

#include<sstream>

#include<iostream>

#include<algorithm>

#define MAXN 100

#define pii pair<int,int>



using namespace std;

char s[MAXN+80];

int main()

{

	int x=0,Max=0,n,i;

	scanf("%d",&n);

	getchar();

	fgets(s,108,stdin);

	for(i=0;i<n;i++)

	{

		x+=s[i]=='I';

		x-=s[i]=='D';

		Max=max(x,Max);

	}

	printf("%d",Max);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.162938778503213x):
#include <stdio.h>



int main(){

	int N, max = 0, x = 0;

	scanf("%d", &N);

	char s[N];

	scanf("%s", s);



	for(int i = 0; s[i] != '\0'; i++){

		if(s[i] == 'I'){

			x ++;

		}else if(s[i] == 'D'){

			x --;

		}if(max < x){

			max = x;

		}

	}

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;

#define LL long long



int main()

{

    int x = 0, mx = 0;

    string s;

    int n;

    cin >> n >> s;

    for(int i=0;i<n;i++){

        if(s[i] == 'I') x++;

        else x--;

        mx = max(x, mx);

    }

    cout << mx  << '\n';

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.266258778953961x):
#include <stdio.h>



int main(){

	int N, max = 0, x = 0;

	scanf("%d", &N);

	char s[N];

	scanf("%s", s);



	for(int i = 0; s[i] != '\0'; i++){

		if(s[i] == 'I'){

			x ++;

		}else if(s[i] == 'D'){

			x --;

		}if(max < x){

			max = x;

		}

	}

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <string>



using namespace std;



int main(){

    

int n;

string s;

cin>>n;

cin>>s;



int x=0,max=0;



for(int i=0; i<s.size();i++){

    

    if(s[i]=='I'){

        

        x++;

        if(x>max){max=x;}

    }else{x--;}

}



cout<<max<<endl;

   

    

}

// Faster C++ solution for the same problem (measured speedup: 5.270649106015488x):
#include <stdio.h>



int main(){

	int N, max = 0, x = 0;

	scanf("%d", &N);

	char s[N];

	scanf("%s", s);



	for(int i = 0; s[i] != '\0'; i++){

		if(s[i] == 'I'){

			x ++;

		}else if(s[i] == 'D'){

			x --;

		}if(max < x){

			max = x;

		}

	}

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string>

using namespace std;



int main()

{

    int n;

    cin>>n;

    string s;

    cin>>s;

    int i=0;

    int arr[n+1];

    arr[0]=0;

    for(int x=0; x<n; x++){

        if(s.at(x)=='I'){

            i++;

        }

        else{

            i--;

        }

        arr[x+1]=i;

    }

    int ans=0;

    for(int x=0; x<=n;x++){

        if(arr[x]>ans){

            ans=arr[x];

        }

    }

    cout<<ans;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.264813575695262x):
#include <stdio.h>



int main(){

	int N, max = 0, x = 0;

	scanf("%d", &N);

	char s[N];

	scanf("%s", s);



	for(int i = 0; s[i] != '\0'; i++){

		if(s[i] == 'I'){

			x ++;

		}else if(s[i] == 'D'){

			x --;

		}if(max < x){

			max = x;

		}

	}

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main()

{

	int n,c=0,x=0;

	string ch;

	cin>>n;

	for(int i=0;i<n;i++)

    {

	cin>>ch[i];

    }

	for(int i=0;i<n;i++)

    { 

    	if(ch[i]=='I')

    	{		

		x++;          

    	c=max(c,x);    

        }

		else if(ch[i]=='D')

    	x--;        	

    	else

    	break;

	}

	cout<<c;



}

// Faster C++ solution for the same problem (measured speedup: 5.21625895800482x):
#include <stdio.h>



int main(){

	int N, max = 0, x = 0;

	scanf("%d", &N);

	char s[N];

	scanf("%s", s);



	for(int i = 0; s[i] != '\0'; i++){

		if(s[i] == 'I'){

			x ++;

		}else if(s[i] == 'D'){

			x --;

		}if(max < x){

			max = x;

		}

	}

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main(){

	int n=0,count=0,max=0;

	string s;

	cin>>n>>s;

	for(int j=0;j<n;j++){

		if(s[j]=='I')

		   count++;

		else

		   count--;

		if(max<count)

		    max=count;      

	}

	cout<<max;

}

// Faster C++ solution for the same problem (measured speedup: 5.221993069976131x):
#include <stdio.h>



int main(){

	int N, max = 0, x = 0;

	scanf("%d", &N);

	char s[N];

	scanf("%s", s);



	for(int i = 0; s[i] != '\0'; i++){

		if(s[i] == 'I'){

			x ++;

		}else if(s[i] == 'D'){

			x --;

		}if(max < x){

			max = x;

		}

	}

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:
#include <iostream>



using namespace std;



int main()

{

    int n;

    cin >> n;

    string s;

    cin >> s;

    int x=0 , max=0;

    for (int i=0 ; i<n ; i++){



        if(s[i]=='I'){

            x++;

            if(x>max)

                max=x;

            }else if (s[i]=='D'){

            x--;

            }

    }

    cout << max<< endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.27078216215838x):
#include <stdio.h>



int main(){

	int N, max = 0, x = 0;

	scanf("%d", &N);

	char s[N];

	scanf("%s", s);



	for(int i = 0; s[i] != '\0'; i++){

		if(s[i] == 'I'){

			x ++;

		}else if(s[i] == 'D'){

			x --;

		}if(max < x){

			max = x;

		}

	}

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 100005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

typedef vector<int> vi;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];

int gcd(int a,int b)

{

    if(b==0){

      return a;

     }

    return gcd(b,a%b);

}

int lcm(int a,int b)

{

    int res=(a*b)/gcd(a,b);

    return res;

}

int po(int a,int b)

{

    int res=1;

    while(b)

    {

        if(b%2!=0)

        {

            res*=a;

            b--;

        }

        else

        {

            a*=a;

            b/=2;

        }

    }

    return res;

}



lln modMul(lln  a, lln b,lln mod){

    lln ans = 0;

    a = a % mod;

    while (b > 0){

        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;

        a = (a%mod * 2%mod) % mod;

        b /= 2;

    }

    return ans % mod;

}

lln powerMod(lln a,lln b,lln mod){

	if(b==0)return 1LL%mod;

	lln x=powerMod( a,b/2,mod );

	x = ( x%mod * x%mod ) % mod;

	if( b%2==1 )x = ( x%mod * a%mod ) % mod;

	return x%mod;

}



int main()

{

   string a;

   int len;

   cin>>len;

   cin>>a;

   int maxi=0;



   int c=0;

   for(int i=0;i<len;i++)

   {

       if(a[i]=='I')

       {

           c++;

           maxi=max(maxi,c);

       }

       else

       {

           c--;

           maxi=max(maxi,c);

       }

   }

   cout<<maxi;



}










// Faster C++ solution for the same problem (measured speedup: 5.221855742895319x):
#include <stdio.h>



int main(){

	int N, max = 0, x = 0;

	scanf("%d", &N);

	char s[N];

	scanf("%s", s);



	for(int i = 0; s[i] != '\0'; i++){

		if(s[i] == 'I'){

			x ++;

		}else if(s[i] == 'D'){

			x --;

		}if(max < x){

			max = x;

		}

	}

	printf("%d\n", max);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cmath>

#include <cstring>

#include <algorithm>

#include <vector>

#include <map>

#include <cstdlib>

#include <set>

#include <queue>

using namespace std;



#define X first

#define Y second

#define N 100010

typedef long long ll;

typedef pair<int,int> pii;

const int Mod=1000000007;



const double INF=1e18;



char s[N];



int main()

{

	//freopen("in.in","r",stdin);

	//freopen("out.out","w",stdout);

	

	int n,x=0,ans=0; scanf("%d",&n);

	scanf("%s",s);

	for (int i=0;i<n;i++)

	{

		if (s[i]=='I') x++;

		else x--;

		ans=max(ans,x);

	}

	cout<<ans<<endl;

	return 0;



}


// Faster C++ solution for the same problem (measured speedup: 5.199495853285691x):
#include <stdio.h>



int main(){

	int n;

	scanf("%d", &n);

	char str[n];

	getchar();

	int x = 0;

	int max = 0;

	for(int i = 0; i < n; i++){

		scanf("%c", &str[i]);

		if(str[i] == 'D'){

			x--;

		} else{

			x++;

		}

		if(x > max){

			max = x;

		}

	}

	printf("%d", max);

	return 0;

}
// Slower C++ solution:
#include<set>

#include<map>

#include<stack>

#include<queue>

#include<deque>

#include<cmath>

#include<cstdio>

#include<cctype>

#include<string>

#include<vector>

#include<cstdlib>

#include<cstring>

#include<sstream>

#include<iostream>

#include<algorithm>

#define MAXN 100

#define pii pair<int,int>



using namespace std;

char s[MAXN+80];

int main()

{

	int x=0,Max=0,n,i;

	scanf("%d",&n);

	getchar();

	fgets(s,108,stdin);

	for(i=0;i<n;i++)

	{

		x+=s[i]=='I';

		x-=s[i]=='D';

		Max=max(x,Max);

	}

	printf("%d",Max);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.174288007223611x):
#include <stdio.h>



int main(){

	int n;

	scanf("%d", &n);

	char str[n];

	getchar();

	int x = 0;

	int max = 0;

	for(int i = 0; i < n; i++){

		scanf("%c", &str[i]);

		if(str[i] == 'D'){

			x--;

		} else{

			x++;

		}

		if(x > max){

			max = x;

		}

	}

	printf("%d", max);

	return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;

#define LL long long



int main()

{

    int x = 0, mx = 0;

    string s;

    int n;

    cin >> n >> s;

    for(int i=0;i<n;i++){

        if(s[i] == 'I') x++;

        else x--;

        mx = max(x, mx);

    }

    cout << mx  << '\n';

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.277835126833971x):
#include <stdio.h>



int main(){

	int n;

	scanf("%d", &n);

	char str[n];

	getchar();

	int x = 0;

	int max = 0;

	for(int i = 0; i < n; i++){

		scanf("%c", &str[i]);

		if(str[i] == 'D'){

			x--;

		} else{

			x++;

		}

		if(x > max){

			max = x;

		}

	}

	printf("%d", max);

	return 0;

}