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

}

// Faster C++ solution for the same problem (measured speedup: 1.4193685979457937x):
#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;

}
// Slower C++ solution:
#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;

}

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

using namespace std;

int a,ans=0,sjx=0;

string x;

int main()

{

	cin>>a>>x;

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

	{

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

			sjx=sjx+1;

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

			sjx=sjx-1;

		if(sjx>ans)

			ans=sjx;

	}

	cout<<ans<<endl;

	return 0;

}
// Slower C++ solution:
#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;

}

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

#include <string>

#include <cmath>

using namespace std;

int cnt, l;

int main() {

    int n;

    cin >> n;

    string s;

    cin >> s;

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

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

            l++;

        }

        else {

            l--;

        }

        cnt = max(l, cnt);

    }

    cout << cnt << endl;

    return 0;

}
// Slower C++ solution:
#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;

}

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

using namespace std;

long long int n;

char s;

long long int ans=0;

long long int ansn=0;

int main(){

    cin>>n;

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

        cin>>s; 

        if(s=='I'){

            ansn++;

        }

        else if(s=='D'){

            ansn--;

        }

        ans=max(ans,ansn);

    }

    cout<<ans;

    return 0;

}
// Slower C++ solution:
#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;

}

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

using namespace std;

int main(){

    int n;

    cin>>n;

    string a;

    cin>>a;

    int ans=0;

    int maxn=0;

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

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

    		ans++;

    		if(ans>maxn){

    			maxn=ans;

			}

		}else{

			ans--;

		}

	}

	cout<<maxn<<endl;

    return 0;

}
// Slower C++ solution:
#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;

  	

}    




// Faster C++ solution for the same problem (measured speedup: 5.284402630666564x):
#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;

}
// Slower C++ solution:
#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;



}


// Faster C++ solution for the same problem (measured speedup: 5.2209315792360655x):
#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,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;

}

// Faster C++ solution for the same problem (measured speedup: 5.262855026179747x):
#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,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;

}

// Faster C++ solution for the same problem (measured speedup: 5.262855026179747x):
#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<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;

 }


// Faster C++ solution for the same problem (measured speedup: 5.269432086211037x):
#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 <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;

}


// Faster C++ solution for the same problem (measured speedup: 5.169231004204591x):
#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<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;



}


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

#include <string.h>





int main (){



    int x;

    int n = 0;

    int big = 0;

    scanf("%d", &x);

    char string[105];

     scanf("%s", string);

    for(int i = 0; i < strlen(string); i++){

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

            n +=1;

            if(big < n) big = n;

        }else n -= 1;

    }

    printf("%d", big);







    return 0;

}
// Slower C++ solution:
#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;

}

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

#include <string.h>





int main (){



    int x;

    int n = 0;

    int big = 0;

    scanf("%d", &x);

    char string[105];

     scanf("%s", string);

    for(int i = 0; i < strlen(string); i++){

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

            n +=1;

            if(big < n) big = n;

        }else n -= 1;

    }

    printf("%d", big);







    return 0;

}
// Slower C++ solution:
#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;

}

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

#include <string.h>





int main (){



    int x;

    int n = 0;

    int big = 0;

    scanf("%d", &x);

    char string[105];

     scanf("%s", string);

    for(int i = 0; i < strlen(string); i++){

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

            n +=1;

            if(big < n) big = n;

        }else n -= 1;

    }

    printf("%d", big);







    return 0;

}
// Slower C++ solution:
#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;

 }


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

#include <string.h>





int main (){



    int x;

    int n = 0;

    int big = 0;

    scanf("%d", &x);

    char string[105];

     scanf("%s", string);

    for(int i = 0; i < strlen(string); i++){

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

            n +=1;

            if(big < n) big = n;

        }else n -= 1;

    }

    printf("%d", big);







    return 0;

}
// Slower C++ solution:
#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;

}


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

#include <string.h>





int main (){



    int x;

    int n = 0;

    int big = 0;

    scanf("%d", &x);

    char string[105];

     scanf("%s", string);

    for(int i = 0; i < strlen(string); i++){

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

            n +=1;

            if(big < n) big = n;

        }else n -= 1;

    }

    printf("%d", big);







    return 0;

}
// Slower C++ solution:
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;

}


// Faster C++ solution for the same problem (measured speedup: 5.2187743860944416x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.223885892127085x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.224794023715436x):
#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;

}
// Slower C++ solution:
#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;



}

// Faster C++ solution for the same problem (measured speedup: 5.220574506826136x):
#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;

}
// Slower C++ solution:


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



}

// Faster C++ solution for the same problem (measured speedup: 5.233370801979001x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.262441916756876x):
#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;

}
// Slower C++ solution:
#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;



}


// Faster C++ solution for the same problem (measured speedup: 5.303417025533637x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 1.803471621875199x):
#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;

}