stablegradients/pie-gem5-pairs huggingface dataset:
// 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.282235104760658x):
#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>

#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.276386746713598x):
#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;

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.22772539572934x):
#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<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.233472112488557x):
#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;



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.282368453389024x):
#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<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.233334483533848x):
#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>

#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.18410084936469x):
#include <stdio.h>



int main (){

	int angka;

	scanf ("%d", &angka);

	

	char str[angka+1];

	scanf("%s", str);

		

		// IIDID

	

	

	int sum = 0;

	int maks = 0;

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

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

			sum ++;	

		}

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

		 sum--;

		}

		if (sum > maks){

			maks = sum;

		}

		

	}

	

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

	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.158967640325105x):
#include <stdio.h>



int main (){

	int angka;

	scanf ("%d", &angka);

	

	char str[angka+1];

	scanf("%s", str);

		

		// IIDID

	

	

	int sum = 0;

	int maks = 0;

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

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

			sum ++;	

		}

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

		 sum--;

		}

		if (sum > maks){

			maks = sum;

		}

		

	}

	

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

	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.262208170920417x):
#include <stdio.h>



int main (){

	int angka;

	scanf ("%d", &angka);

	

	char str[angka+1];

	scanf("%s", str);

		

		// IIDID

	

	

	int sum = 0;

	int maks = 0;

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

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

			sum ++;	

		}

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

		 sum--;

		}

		if (sum > maks){

			maks = sum;

		}

		

	}

	

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

	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.266595121107618x):
#include <stdio.h>



int main (){

	int angka;

	scanf ("%d", &angka);

	

	char str[angka+1];

	scanf("%s", str);

		

		// IIDID

	

	

	int sum = 0;

	int maks = 0;

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

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

			sum ++;	

		}

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

		 sum--;

		}

		if (sum > maks){

			maks = sum;

		}

		

	}

	

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

	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.260764079257667x):
#include <stdio.h>



int main (){

	int angka;

	scanf ("%d", &angka);

	

	char str[angka+1];

	scanf("%s", str);

		

		// IIDID

	

	

	int sum = 0;

	int maks = 0;

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

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

			sum ++;	

		}

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

		 sum--;

		}

		if (sum > maks){

			maks = sum;

		}

		

	}

	

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

	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.2122468079515825x):
#include <stdio.h>



int main (){

	int angka;

	scanf ("%d", &angka);

	

	char str[angka+1];

	scanf("%s", str);

		

		// IIDID

	

	

	int sum = 0;

	int maks = 0;

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

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

			sum ++;	

		}

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

		 sum--;

		}

		if (sum > maks){

			maks = sum;

		}

		

	}

	

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

	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.2179765094597945x):
#include <stdio.h>



int main (){

	int angka;

	scanf ("%d", &angka);

	

	char str[angka+1];

	scanf("%s", str);

		

		// IIDID

	

	

	int sum = 0;

	int maks = 0;

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

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

			sum ++;	

		}

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

		 sum--;

		}

		if (sum > maks){

			maks = sum;

		}

		

	}

	

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

	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.266728074908732x):
#include <stdio.h>



int main (){

	int angka;

	scanf ("%d", &angka);

	

	char str[angka+1];

	scanf("%s", str);

		

		// IIDID

	

	

	int sum = 0;

	int maks = 0;

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

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

			sum ++;	

		}

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

		 sum--;

		}

		if (sum > maks){

			maks = sum;

		}

		

	}

	

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

	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.217839288005805x):
#include <stdio.h>



int main (){

	int angka;

	scanf ("%d", &angka);

	

	char str[angka+1];

	scanf("%s", str);

		

		// IIDID

	

	

	int sum = 0;

	int maks = 0;

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

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

			sum ++;	

		}

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

		 sum--;

		}

		if (sum > maks){

			maks = sum;

		}

		

	}

	

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

	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;

    int Max = 0;



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

        if (s[i] == 73){

            x++;

        }else if (s[i] == 68){

            x--;

        }



        if (x > Max){

            Max = x;

        }

    }



    cout << Max << endl;

}

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



int main(){

    int n, max=0, sum=0;

    char s[105];

    scanf("%d",&n);

    scanf("%s",s);

    

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

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

            sum++;

        }

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

            sum--;

        }

        if(max < sum){

            max = sum;

        }

    }

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

    return 0;

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

using namespace std;

int main(){

	int N,i,num=0,max=0;

	char a;

	cin>>N;

	for(i=0;i<N;i++){

		cin>>a;

		if(a=='I')

		num++;

		else

		num--;

		if(max<num)

		max=num;

	}

	cout<<max;

	return 0;

}

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



int main(){

    int n, max=0, sum=0;

    char s[105];

    scanf("%d",&n);

    scanf("%s",s);

    

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

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

            sum++;

        }

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

            sum--;

        }

        if(max < sum){

            max = sum;

        }

    }

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

    return 0;

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

using namespace std;

int main()

{

	int n,counter=0,mx=0;

	cin>>n;

	

	string s;

	cin.ignore();

	getline(cin,s);

	

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

	{

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

		{

			counter++;

		}

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

		{

			counter--;

		}

		if(mx<counter)

		{

			mx=counter;

		}

	}

	cout<<mx;

}

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



int main(){

    int n, max=0, sum=0;

    char s[105];

    scanf("%d",&n);

    scanf("%s",s);

    

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

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

            sum++;

        }

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

            sum--;

        }

        if(max < sum){

            max = sum;

        }

    }

    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;

    int Max = 0;



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

        if (s[i] == 73){

            x++;

        }else if (s[i] == 68){

            x--;

        }



        if (x > Max){

            Max = x;

        }

    }



    cout << Max << endl;

}

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



int main(){

	int n;

	scanf("%d", &n);

	char str[100];

	scanf("%s", str);



	int ans[n];

	int x = 0;

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

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

			x++;

			ans[i] = x;

		}

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

			x--;

			ans[i] = x;

		}

	}



	int max = 0;

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

		if (max < ans[i]){

			max = ans[i];

		}

	}



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



	return 0;

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

using namespace std;

int main(){

	int N,i,num=0,max=0;

	char a;

	cin>>N;

	for(i=0;i<N;i++){

		cin>>a;

		if(a=='I')

		num++;

		else

		num--;

		if(max<num)

		max=num;

	}

	cout<<max;

	return 0;

}

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



int main(){

	int n;

	scanf("%d", &n);

	char str[100];

	scanf("%s", str);



	int ans[n];

	int x = 0;

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

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

			x++;

			ans[i] = x;

		}

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

			x--;

			ans[i] = x;

		}

	}



	int max = 0;

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

		if (max < ans[i]){

			max = ans[i];

		}

	}



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



	return 0;

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

using namespace std;

int main()

{

	int n,counter=0,mx=0;

	cin>>n;

	

	string s;

	cin.ignore();

	getline(cin,s);

	

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

	{

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

		{

			counter++;

		}

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

		{

			counter--;

		}

		if(mx<counter)

		{

			mx=counter;

		}

	}

	cout<<mx;

}

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



int main(){

	int n;

	scanf("%d", &n);

	char str[100];

	scanf("%s", str);



	int ans[n];

	int x = 0;

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

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

			x++;

			ans[i] = x;

		}

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

			x--;

			ans[i] = x;

		}

	}



	int max = 0;

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

		if (max < ans[i]){

			max = ans[i];

		}

	}



	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;

    int Max = 0;



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

        if (s[i] == 73){

            x++;

        }else if (s[i] == 68){

            x--;

        }



        if (x > Max){

            Max = x;

        }

    }



    cout << Max << endl;

}

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

int main() {

	int n;

	scanf("%d", &n);

	char s[n+1];

	scanf("%s", s);

	int x = 0, max = 0;

	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,i,num=0,max=0;

	char a;

	cin>>N;

	for(i=0;i<N;i++){

		cin>>a;

		if(a=='I')

		num++;

		else

		num--;

		if(max<num)

		max=num;

	}

	cout<<max;

	return 0;

}

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

int main() {

	int n;

	scanf("%d", &n);

	char s[n+1];

	scanf("%s", s);

	int x = 0, max = 0;

	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,counter=0,mx=0;

	cin>>n;

	

	string s;

	cin.ignore();

	getline(cin,s);

	

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

	{

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

		{

			counter++;

		}

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

		{

			counter--;

		}

		if(mx<counter)

		{

			mx=counter;

		}

	}

	cout<<mx;

}

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

int main() {

	int n;

	scanf("%d", &n);

	char s[n+1];

	scanf("%s", s);

	int x = 0, max = 0;

	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;

    int Max = 0;



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

        if (s[i] == 73){

            x++;

        }else if (s[i] == 68){

            x--;

        }



        if (x > Max){

            Max = x;

        }

    }



    cout << Max << endl;

}

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



int main(){

	int n,out=0, max=0;

	char cha[101];

	scanf("%d", &n);

	scanf("%s", cha);

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

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

			out++;

		}else{

			out--;

		}

		if(max<out){

			max=out;

		}

	}

	printf("%d", max);

	

	return 0;

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

using namespace std;

int main(){

	int N,i,num=0,max=0;

	char a;

	cin>>N;

	for(i=0;i<N;i++){

		cin>>a;

		if(a=='I')

		num++;

		else

		num--;

		if(max<num)

		max=num;

	}

	cout<<max;

	return 0;

}

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



int main(){

	int n,out=0, max=0;

	char cha[101];

	scanf("%d", &n);

	scanf("%s", cha);

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

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

			out++;

		}else{

			out--;

		}

		if(max<out){

			max=out;

		}

	}

	printf("%d", max);

	

	return 0;

}