unittest
{
	assert( [ "5", "IIDID" ].parse.expand.solve == 2 );
	assert( [ "7", "DDIDDII" ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto s = input.front;
	return tuple( s );
}

auto solve( string s )
{
	auto ans = 0L;
	auto x = 0L;
	
	foreach( c; s )
	{
		switch( c )
		{
			case 'I': x++; ans = max( ans, x ); break;
			case 'D': x--;                      break;
			default : assert( false );
		}
	}
	
	return ans;
}
