stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#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;

   

    

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;



}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):


#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;



}










// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main()

{

    int a[100000]={},n,j,max=0;

    char b[100000];

    cin>>n;

    for(j=1;j<n+1;j++)

        cin>>b[j];

    for(j=1;j<n+1;j++)

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

            a[j]=a[j-1]+1;

        else

            a[j]=a[j-1]-1;

    for(j=0;j<n+1;j++)

        if(a[j]>max)

            max=a[j];

    cout<<max<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

int N,i,ans,t;

char s;

int main()

{

	scanf("%d\n",&N);

	for(i=1;i<=N;i++)

	{

		scanf("%c",&s);

		if(s=='I')

		t++;

		else if(s=='D')

		t--;

		ans=max(t,ans);

	}

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

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main(){

	int n;

  	cin>>n;

    string s;

  	cin>>s;

  	int mymax=0;

  	int ans=0;

  	

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

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

        	ans++;	

        }

      	if(s.at(i)=='D'){

        	ans--;

        }

      	mymax=max(mymax,ans);

    }

  	cout<<mymax<<endl;

  	

}    




// Optimized solution to the same problem (faster):
#include<cstdio>

#define pritnf printf

#define scnaf scanf

#define retrun return

#define sizoef sizeof

#define inl inline

#define br break

#define con continue

#define mst(a,b) memset(a,b,sizeof(a))

#define fora(x,a,b) for(re nti (x)=(a);(x)<=(b);++(x))

#define forb(x,a,b) for(re nit (x)=(a);(x)>=(b);--(x))

#define re register

#define stt struct

#define infa (0x3f3f3f3f)

#define infb (0x7fffffff)

#define infd (0x7f)

#define abss(x) ((x)>(0)?(x):(-1)*(x))

#define maxx(a,b) ((a)>(b)?(a):(b))

#define minn(a,b) ((a)<(b)?(a):(b))

#define pf(_) ((_)*(_))

#define in(a) freopen("D:/""/in"a".in","r",stdin)

#define out(a) freopen("D:/""/out"a".out","w",stdout)

typedef long long ll;

typedef int itn,nti,tin,tni,nit;

using namespace std;

const nit maxa=10004;

const nit maxb=1e2;

const nit maxc=5;



char x;

tni n,dq=0,ans=0;



tin main()

{

	scanf("%d\n",&n);

	fora(i,1,n)

	{

		x=getchar();

		if(x=='I')

		{

			++dq;

		}

		else if(x=='D')

		{

			--dq;

		}

		//

		if(dq>ans)

		{

			ans=dq;

		}

	}

	//

	pritnf("%d\n",ans);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include<bits/stdc++.h>

using namespace std;



int main()

{

    int n;

    int x=0;

    int max1=0;

    cin>>n;

    string s;

    cin>>s;

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

    {

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

        {

            x++;

            if(x>max1)

            {

                max1=x;

            }

        }

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

        {

            x--;

            if(x>max1)

            {

                max1=x;

            }

        }

    }

        cout<<max1;





    return 0;



}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

int n,c=0,max=0;

string s;

cin>>n>>s;

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

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

	{

		c++;

	}

	else{

		c--;

	}

	if(max<c){

		max=c;

	}

}

cout<<max;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

int main(){

int n,c=0,max=0;

string s;

cin>>n>>s;

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

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

c++;}

else{

c--;}

if(max<c){

max=c;

}

}

cout<<max;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<string>

using namespace std;

int main()

{

    int a;

    cin>>a;

    string s;

    cin>>s;

    int sum=0;

    int max1=0;

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

     {

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

         {

             sum++;

         }

         else

         {

             sum--;

         }

         max1=max(sum,max1);

     }

     cout<<max1<<endl;

     return 0;

 }


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <cstdio>

#include <cstring>

using namespace std;

typedef long long ll;

const int maxn = 110;

char str[maxn];

int q, num, ans;

int main()

{

    while(~scanf("%d",&q))

    {

        memset(str,0,sizeof(str));

        ans = 0; num = 0;

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

        {

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

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

            {

                num++;

                ans = max(ans,num);

            }

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

            {

                num--;

                ans = max(ans,num);

            }

        }

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

    }

    return 0;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
using namespace std;

#include<iostream>

 

int main()

{

    int N;

    cin>>N;

    char S[N];

    int x=0,max=0;

    for(int j=0;j<N;j++)

    cin>>S[j];

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

    {

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

        x++;

        else

        x--;

 

        if(x>=max)

        max=x;

 

    }

    cout<<max;

    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>



int main(){

    int a,x=0, max=0;

    scanf("%d", &a);

    char b[101];

    scanf("%s", b);

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

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

        x++;

        else

        x--;

        if (max<x){

            max=x;

        }

    }

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

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <string>

using namespace std;



int main()

{

    int N,Max=0,num=0;

    string s;



    cin>>N;



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

    {

        cin>>s[i];

    }



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

    {

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

            num++;

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

            num--;



        if(num>Max)

            Max=num;

    }



    cout << Max << endl;



    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>



int main(){

    int a,x=0, max=0;

    scanf("%d", &a);

    char b[101];

    scanf("%s", b);

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

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

        x++;

        else

        x--;

        if (max<x){

            max=x;

        }

    }

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

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

using Long = long long;

int main() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    Long x = 0;

    Long ans = 0;

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

        ans = max(ans,x);

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

        else x++;

        ans = max(ans,x);

    }

    cout << ans << endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



int main(){

    int a,x=0, max=0;

    scanf("%d", &a);

    char b[101];

    scanf("%s", b);

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

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

        x++;

        else

        x--;

        if (max<x){

            max=x;

        }

    }

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

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <string>



using namespace std;



int main()

{

	string s;

	int x = 0, max = 0, count = 0;

	cin >> x >> s;



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

	{

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

			count++;

		}

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

			count--;

		}

		if (count > max) {

			max = count;

		}

	}

	cout << max;



}

// Optimized solution to the same problem (faster):
#include<stdio.h>



int main(){

    int a,x=0, max=0;

    scanf("%d", &a);

    char b[101];

    scanf("%s", b);

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

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

        x++;

        else

        x--;

        if (max<x){

            max=x;

        }

    }

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

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):


#include<bits/stdc++.h>

using namespace std;

int main(){

int N,x=0,ans=0;

string S;

scanf("%d\n",&N);

getline(cin,S);

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

{

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

    ++x;

    else

    --x;

    if(x>=ans)

        ans=x;





}

printf("%d",ans);



}

// Optimized solution to the same problem (faster):
#include<stdio.h>



int main(){

    int a,x=0, max=0;

    scanf("%d", &a);

    char b[101];

    scanf("%s", b);

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

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

        x++;

        else

        x--;

        if (max<x){

            max=x;

        }

    }

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

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main(){

	int n;

	string s;

	cin>>n>>s;

	int x=0;

	int max=x;

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

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

		x++;

		else 

		x--;

		if(max<x)

		max=x;

		

	}

	cout<<max;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



int main(){

    int a,x=0, max=0;

    scanf("%d", &a);

    char b[101];

    scanf("%s", b);

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

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

        x++;

        else

        x--;

        if (max<x){

            max=x;

        }

    }

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

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

  

using namespace std;

  

template<class T> void ckmin(T &a, T b) { a = min(a, b); }

template<class T> void ckmax(T &a, T b) { a = max(a, b); }

  

#define pb push_back

#define mp make_pair

#define cotu cout

#define itn int

#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define F first

#define S second

#define sz(x) (int)x.size()

#define all(x) (x).begin(), (x).end()

#define rep(i, n) for(int i = 0; i < n; ++i)

#define repr(i,n) for(int i = n - 1; i >= 0; --i)

#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)

#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)

#define Repr(i, a, n) for(int i = (n); i >= (a); --i)

#define setp(x) fixed << setprecision(x)

#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 

  

#include <ext/pb_ds/assoc_container.hpp> 

#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 

  

typedef long long ll;

typedef pair<ll, ll> pll;

typedef pair<int, int> pii;

  

const int inf = int(1e9);

const int mod = inf + 7;

const int N = 1e6 + 555; // TL MB

const double PI = acos(-1.0);

void mul(ll &x, ll y){

	x *= y;

	if(x >= mod) x %= mod;

}

 

void add(ll &x, ll y){

	x += y;

	if(x >= mod) x -= mod;

	if(x < 0) x += mod;

}

ll bp(ll a, ll n){

	ll r = 1;

	while(n){

		if(n & 1) mul(r, a);

		mul(a, a);

		n >>= 1;

	}

 	return r;

}



void solve()

{

	int n;

	cin >> n;

	string s;

	cin >> s;

	int res = 0, bal = 0;

	rep(i, sz(s)) (bal += (s[i] == 'I' ? 1 : -1)), ckmax(res, bal);

	cout << res;

} 

int main()

{

	// freopen("input.txt", "r", stdin);

	// freopen("output.txt", "w", stdout);

    Red;

  	int T = 1;

  	// cin >> T;

  	for(int i = 1; i <= T; ++i){

  		solve();

  	}

  	return 0;



}


// Optimized solution to the same problem (faster):
#include<stdio.h>



int main(){

    int a,x=0, max=0;

    scanf("%d", &a);

    char b[101];

    scanf("%s", b);

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

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

        x++;

        else

        x--;

        if (max<x){

            max=x;

        }

    }

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

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstring>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <functional>

#include <vector>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <bitset>

#include <cassert>

#include <exception>

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef pair<int,int> P;

#define rep(i,a,n) for(ll i = (a);i < (n);i++)

#define per(i,a,n) for(ll i = (a);i > (n);i--)

#define lep(i,a,n) for(ll i = (a);i <= (n);i++)

#define pel(i,a,n) for(ll i = (a);i >= (n);i--)

#define clr(a,b) memset((a),(b),sizeof(a))

#define pb push_back

#define mp make_pair

#define all(c) (c).begin(),(c).end()

#define sz size()

#define print(X) cout << (X) << endl

const ll INF = 1e+9+7;

ll n,m,l;

string s,t;

ll d[100000],dp[100][100];



int main(){

  cin >> n >> s;

  clr(d,0);

  rep(i,0,n){

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

    else d[i]++;

  }

  l = 0;

  rep(i,0,n){

    l = max(l,d[i]);

    d[i+1] += d[i];

  }

  print(l);

  return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <cstring>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <functional>

#include <vector>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <bitset>

#include <cassert>

#include <exception>

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef pair<ll,ll> P;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef vector<string> vs;

typedef vector<P> vp;

#define rep(i,a,n) for(ll i = (a);i < (n);i++)

#define per(i,a,n) for(ll i = (a);i > (n);i--)

#define lep(i,a,n) for(ll i = (a);i <= (n);i++)

#define pel(i,a,n) for(ll i = (a);i >= (n);i--)

#define clr(a,b) memset((a),(b),sizeof(a))

#define pb push_back

#define mp make_pair

#define all(c) (c).begin(),(c).end()

#define sz size()

#define print(X) cout << (X) << endl

const ll INF = 1e+9+7;

ll n,m,l;

string s,t;

ll d[200010],dp[500][500];



int main(){

  cin >> n >> s;

  rep(i,0,s.sz){

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

    else d[i]--;

    d[i+1] = d[i];

  }

  ll ans = 0;

  rep(i,0,s.sz){

    ans = max(ans,d[i]);

  }

  print(ans);

  return 0;

}

// Fastest known solution for this problem: