#include<iostream>
using namespace std;
int N;
int A[1<<17];
int cnt;
int main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<N;)
	{
		cnt++;
		int j=i;
		while(j<N&&A[i]==A[j])j++;
		if(j==N)break;
		if(A[i]<A[j])
		{
			while(j+1<N&&A[j]<=A[j+1])j++;
		}
		else
		{
			while(j+1<N&&A[j]>=A[j+1])j++;
		}
		i=j+1;
	}
	cout<<cnt<<endl;
}
