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

#include <bits/stdc++.h>

#include <string>

#include <cmath>



using namespace std;





int main()

{

   int x=0;

   int mx=0;

   int n;

   char a;

   cin>>n;

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

   {

       cin>>a;

       if(a=='I') x+=1;

       else if(a=='D') x-=1;

    if(x>mx)

        mx=x;

   }

   cout<<mx;

     return 0;

}


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



int main(){

	int n;

	scanf("%d", &n);

	char id[n];

	

	int x = 0;

	int max = 0;

	

	scanf("%s", id);

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

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

			x++;

			if(max < x){

				max = x;

			}

		}

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

			x--;

		}

	}

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

	return 0;

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



using namespace std;



int main() {

    long long len,x=0,maxx=0;

    string s;

    cin >> len>>s;

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

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

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

        if(x>maxx){

            maxx=x;

        }

    }

    cout << maxx;

    return 0;

}

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



int main(){

	int n;

	scanf("%d", &n);

	char id[n];

	

	int x = 0;

	int max = 0;

	

	scanf("%s", id);

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

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

			x++;

			if(max < x){

				max = x;

			}

		}

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

			x--;

		}

	}

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

	return 0;

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

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<algorithm>

//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector

//#include<bits/stdc++.h>

#define ll long long

using namespace std;





int main() {

	ios::sync_with_stdio(false);

	ll a,b,c,d;

	cin>>a;

	string s;

	cin>>s;

	ll sum=0;

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



int main(){

	int n;

	scanf("%d", &n);

	char id[n];

	

	int x = 0;

	int max = 0;

	

	scanf("%s", id);

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

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

			x++;

			if(max < x){

				max = x;

			}

		}

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

			x--;

		}

	}

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

	return 0;

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

using namespace std;

int main(){

	int n ,x=0 ,max=0;

	scanf("%d",&n);

	char s[n];

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

	 cin>>s[i];

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

	 	++x;

	 	++i;

	 	

	 }

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

	 	--x;

     	++i;

	 }

	 if(x>max)

	 max=x;

	}

	printf("%d",max);

}

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



int main(){

	int n;

	scanf("%d", &n);

	char id[n];

	

	int x = 0;

	int max = 0;

	

	scanf("%s", id);

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

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

			x++;

			if(max < x){

				max = x;

			}

		}

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

			x--;

		}

	}

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

	return 0;

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



int main(){

	int n;

	scanf("%d", &n);

	char id[n];

	

	int x = 0;

	int max = 0;

	

	scanf("%s", id);

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

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

			x++;

			if(max < x){

				max = x;

			}

		}

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

			x--;

		}

	}

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

	return 0;

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

#include <cmath>

using namespace std;



int main()

{

    int n,x=0,y=0;

    string s;

    cin>>n;

    cin>>s;

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

    {

        if(s[i]=='I') {x+=1; y=max(y,x);}

        else          {x-=1; y=max(y,x);}

    }

    cout << y << endl;

    return 0;

}


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

int main(){

	int a, c=0, max=0;

	scanf("%d", &a);

	char b[a+1];

	scanf("%s", b);

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

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

			c--;

		}

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

			c++;

		}

		if(max<c){

			max=c;

		}

	}

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

	return 0;

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

#include <bits/stdc++.h>

#include <string>

#include <cmath>



using namespace std;





int main()

{

   int x=0;

   int mx=0;

   int n;

   char a;

   cin>>n;

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

   {

       cin>>a;

       if(a=='I') x+=1;

       else if(a=='D') x-=1;

    if(x>mx)

        mx=x;

   }

   cout<<mx;

     return 0;

}


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

int main(){

	int a, c=0, max=0;

	scanf("%d", &a);

	char b[a+1];

	scanf("%s", b);

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

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

			c--;

		}

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

			c++;

		}

		if(max<c){

			max=c;

		}

	}

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

	return 0;

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



using namespace std;



int main() {

    long long len,x=0,maxx=0;

    string s;

    cin >> len>>s;

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

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

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

        if(x>maxx){

            maxx=x;

        }

    }

    cout << maxx;

    return 0;

}

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

int main(){

	int a, c=0, max=0;

	scanf("%d", &a);

	char b[a+1];

	scanf("%s", b);

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

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

			c--;

		}

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

			c++;

		}

		if(max<c){

			max=c;

		}

	}

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

	return 0;

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

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<algorithm>

//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector

//#include<bits/stdc++.h>

#define ll long long

using namespace std;





int main() {

	ios::sync_with_stdio(false);

	ll a,b,c,d;

	cin>>a;

	string s;

	cin>>s;

	ll sum=0;

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

int main(){

	int a, c=0, max=0;

	scanf("%d", &a);

	char b[a+1];

	scanf("%s", b);

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

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

			c--;

		}

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

			c++;

		}

		if(max<c){

			max=c;

		}

	}

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

	return 0;

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

using namespace std;

int main(){

	int n ,x=0 ,max=0;

	scanf("%d",&n);

	char s[n];

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

	 cin>>s[i];

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

	 	++x;

	 	++i;

	 	

	 }

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

	 	--x;

     	++i;

	 }

	 if(x>max)

	 max=x;

	}

	printf("%d",max);

}

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

int main(){

	int a, c=0, max=0;

	scanf("%d", &a);

	char b[a+1];

	scanf("%s", b);

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

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

			c--;

		}

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

			c++;

		}

		if(max<c){

			max=c;

		}

	}

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

	return 0;

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

int main(){

	int a, c=0, max=0;

	scanf("%d", &a);

	char b[a+1];

	scanf("%s", b);

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

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

			c--;

		}

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

			c++;

		}

		if(max<c){

			max=c;

		}

	}

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

	return 0;

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

#include <cmath>

using namespace std;



int main()

{

    int n,x=0,y=0;

    string s;

    cin>>n;

    cin>>s;

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

    {

        if(s[i]=='I') {x+=1; y=max(y,x);}

        else          {x-=1; y=max(y,x);}

    }

    cout << y << endl;

    return 0;

}


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

#include <string.h>



int main(){

	int a;

	scanf("%d", &a);

	

	int x = 0;

	int jml = 0;

	

	char array[100];

	scanf("%s", array);

	

	int arraylen = strlen(array);

	

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

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

			jml++;

		}

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

			jml--;

		}

		if(x < jml){

			x = jml;

		}

	}

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

	return 0;

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

#include <bits/stdc++.h>

#include <string>

#include <cmath>



using namespace std;





int main()

{

   int x=0;

   int mx=0;

   int n;

   char a;

   cin>>n;

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

   {

       cin>>a;

       if(a=='I') x+=1;

       else if(a=='D') x-=1;

    if(x>mx)

        mx=x;

   }

   cout<<mx;

     return 0;

}


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

#include <string.h>



int main(){

	int a;

	scanf("%d", &a);

	

	int x = 0;

	int jml = 0;

	

	char array[100];

	scanf("%s", array);

	

	int arraylen = strlen(array);

	

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

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

			jml++;

		}

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

			jml--;

		}

		if(x < jml){

			x = jml;

		}

	}

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

	return 0;

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



using namespace std;



int main() {

    long long len,x=0,maxx=0;

    string s;

    cin >> len>>s;

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

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

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

        if(x>maxx){

            maxx=x;

        }

    }

    cout << maxx;

    return 0;

}

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

#include <string.h>



int main(){

	int a;

	scanf("%d", &a);

	

	int x = 0;

	int jml = 0;

	

	char array[100];

	scanf("%s", array);

	

	int arraylen = strlen(array);

	

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

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

			jml++;

		}

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

			jml--;

		}

		if(x < jml){

			x = jml;

		}

	}

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

	return 0;

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

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<algorithm>

//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector

//#include<bits/stdc++.h>

#define ll long long

using namespace std;





int main() {

	ios::sync_with_stdio(false);

	ll a,b,c,d;

	cin>>a;

	string s;

	cin>>s;

	ll sum=0;

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

#include <string.h>



int main(){

	int a;

	scanf("%d", &a);

	

	int x = 0;

	int jml = 0;

	

	char array[100];

	scanf("%s", array);

	

	int arraylen = strlen(array);

	

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

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

			jml++;

		}

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

			jml--;

		}

		if(x < jml){

			x = jml;

		}

	}

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

	return 0;

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

using namespace std;

int main(){

	int n ,x=0 ,max=0;

	scanf("%d",&n);

	char s[n];

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

	 cin>>s[i];

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

	 	++x;

	 	++i;

	 	

	 }

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

	 	--x;

     	++i;

	 }

	 if(x>max)

	 max=x;

	}

	printf("%d",max);

}

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

#include <string.h>



int main(){

	int a;

	scanf("%d", &a);

	

	int x = 0;

	int jml = 0;

	

	char array[100];

	scanf("%s", array);

	

	int arraylen = strlen(array);

	

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

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

			jml++;

		}

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

			jml--;

		}

		if(x < jml){

			x = jml;

		}

	}

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

	return 0;

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

#include <string.h>



int main(){

	int a;

	scanf("%d", &a);

	

	int x = 0;

	int jml = 0;

	

	char array[100];

	scanf("%s", array);

	

	int arraylen = strlen(array);

	

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

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

			jml++;

		}

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

			jml--;

		}

		if(x < jml){

			x = jml;

		}

	}

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

	return 0;

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

#include <cmath>

using namespace std;



int main()

{

    int n,x=0,y=0;

    string s;

    cin>>n;

    cin>>s;

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

    {

        if(s[i]=='I') {x+=1; y=max(y,x);}

        else          {x-=1; y=max(y,x);}

    }

    cout << y << endl;

    return 0;

}


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



int main(){

    int test;

    scanf("%d", &test);

    getchar();

    char word[test];

    int x = 0;

    int max = 0;

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

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

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

            x--;

        }else{

            x++;

        }

        if(x > max){

            max = x;

        }

    }

    printf("%d", max);

    return 0;

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

#include <bits/stdc++.h>

#include <string>

#include <cmath>



using namespace std;





int main()

{

   int x=0;

   int mx=0;

   int n;

   char a;

   cin>>n;

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

   {

       cin>>a;

       if(a=='I') x+=1;

       else if(a=='D') x-=1;

    if(x>mx)

        mx=x;

   }

   cout<<mx;

     return 0;

}


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



int main(){

    int test;

    scanf("%d", &test);

    getchar();

    char word[test];

    int x = 0;

    int max = 0;

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

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

        if(word[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() {

    long long len,x=0,maxx=0;

    string s;

    cin >> len>>s;

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

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

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

        if(x>maxx){

            maxx=x;

        }

    }

    cout << maxx;

    return 0;

}

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



int main(){

    int test;

    scanf("%d", &test);

    getchar();

    char word[test];

    int x = 0;

    int max = 0;

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

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

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

            x--;

        }else{

            x++;

        }

        if(x > max){

            max = x;

        }

    }

    printf("%d", max);

    return 0;

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

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<algorithm>

//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector

//#include<bits/stdc++.h>

#define ll long long

using namespace std;





int main() {

	ios::sync_with_stdio(false);

	ll a,b,c,d;

	cin>>a;

	string s;

	cin>>s;

	ll sum=0;

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



int main(){

    int test;

    scanf("%d", &test);

    getchar();

    char word[test];

    int x = 0;

    int max = 0;

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

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

        if(word[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 ,x=0 ,max=0;

	scanf("%d",&n);

	char s[n];

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

	 cin>>s[i];

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

	 	++x;

	 	++i;

	 	

	 }

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

	 	--x;

     	++i;

	 }

	 if(x>max)

	 max=x;

	}

	printf("%d",max);

}

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



int main(){

    int test;

    scanf("%d", &test);

    getchar();

    char word[test];

    int x = 0;

    int max = 0;

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

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

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

            x--;

        }else{

            x++;

        }

        if(x > max){

            max = x;

        }

    }

    printf("%d", max);

    return 0;

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



int main(){

    int test;

    scanf("%d", &test);

    getchar();

    char word[test];

    int x = 0;

    int max = 0;

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

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

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

            x--;

        }else{

            x++;

        }

        if(x > max){

            max = x;

        }

    }

    printf("%d", max);

    return 0;

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

#include <cmath>

using namespace std;



int main()

{

    int n,x=0,y=0;

    string s;

    cin>>n;

    cin>>s;

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

    {

        if(s[i]=='I') {x+=1; y=max(y,x);}

        else          {x-=1; y=max(y,x);}

    }

    cout << y << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.279965590193801x):
#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 <bits/stdc++.h>

#include <string>

#include <cmath>



using namespace std;





int main()

{

   int x=0;

   int mx=0;

   int n;

   char a;

   cin>>n;

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

   {

       cin>>a;

       if(a=='I') x+=1;

       else if(a=='D') x-=1;

    if(x>mx)

        mx=x;

   }

   cout<<mx;

     return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.228949647856835x):
#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 <bits/stdc++.h>



using namespace std;



int main() {

    long long len,x=0,maxx=0;

    string s;

    cin >> len>>s;

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

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

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

        if(x>maxx){

            maxx=x;

        }

    }

    cout << maxx;

    return 0;

}

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

#include<cstdlib>

#include<cmath>

#include<algorithm>

//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector

//#include<bits/stdc++.h>

#define ll long long

using namespace std;





int main() {

	ios::sync_with_stdio(false);

	ll a,b,c,d;

	cin>>a;

	string s;

	cin>>s;

	ll sum=0;

	ll 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.351615749287402x):
#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<bits/stdc++.h>

using namespace std;

int main(){

	int n ,x=0 ,max=0;

	scanf("%d",&n);

	char s[n];

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

	 cin>>s[i];

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

	 	++x;

	 	++i;

	 	

	 }

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

	 	--x;

     	++i;

	 }

	 if(x>max)

	 max=x;

	}

	printf("%d",max);

}

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

}