#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 50;
int a[N];
int main()
{
    /* int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", a + i);
    a[0] = a[n + 1] = 0x3f3f3f3f;
    int cnt = 0;
    for (int i = 1; i <= n; i++)
        if (a[i - 1] <= a[i] && a[i] >= a[i + 1])
            cnt++;
    cout << cnt;
    return 0;*/
    int n;
    scanf("%d", &n);
    int d = 0, last = 2147483640, os = 1;
    for (int i = 1; i <= n; i++)
    {
        int s;
        scanf("%d", &s);
        if (os == 1)
        {
            if (last > s)
            {
                last = s;
            }
            else
            {
                os = 2;
                last = s;
                d++;
                continue;
            }
        }
        else if (os == 2)
        {
            if (last < s)
            {
                last = s;
            }
            else
            {
                os = 1;
                last = s;
			}
        }
    }
    printf("%d\n", d);
    return 0;
}
