unittest
{
	assert( [ "6", "1 2 3 2 2 1" ].parse.expand.solve == 2 );
	assert( [ "9", "1 2 1 2 1 2 1 2 1" ].parse.expand.solve == 5 );
	assert( [ "7", "1 2 3 2 1 999999999 1000000000" ].parse.expand.solve == 3 );
	
	assert( [ "1", "100" ].parse.expand.solve == 1 );		// 追加ケース
}



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 ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto ans = 1L;
	auto d = 0L;
	for( auto i = 0L; i + 1 < as.length; i++ )
	{
		if( 0 <= d && as[ i ] <= as[ i + 1 ] )
		{
			d = ( as[ i ] == as[ i + 1 ] ) ? 0 : 1;
			continue;
		}
		if( d <= 0 && as[ i + 1 ] <= as[ i ] )
		{
			d = ( as[ i ] == as[ i + 1 ] ) ? 0 : -1;
			continue;
		}
		d = 0;
		ans++;
	}
	return ans;
}
