#include <bits/stdc++.h>
using namespace std;
int n, a[109], dp[109][2];
int main() {
scanf("%d", &n);
for(int i = 0; i < n; i++) scanf("%d", &a[i]);
for(int i = 0; i < n; i++) {
dp[i][0] = dp[i][1] = 1;
for(int j = 0; j < i; j++) {
if(a[j] > a[i]) dp[i][0] = max(dp[i][0], dp[j][1] + 1);
if(a[j] < a[i]) dp[i][1] = max(dp[i][1], dp[j][0] + 1);
}
}
cout << n - max(dp[n - 1][0], dp[n - 1][1]) << endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBuLCBhWzEwOV0sIGRwWzEwOV1bMl07CmludCBtYWluKCkgewogICAgc2NhbmYoIiVkIiwgJm4pOwogICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKykgc2NhbmYoIiVkIiwgJmFbaV0pOwogICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKykgewogICAgICAgIGRwW2ldWzBdID0gZHBbaV1bMV0gPSAxOwogICAgICAgIGZvcihpbnQgaiA9IDA7IGogPCBpOyBqKyspIHsKICAgICAgICAgICAgaWYoYVtqXSA+IGFbaV0pIGRwW2ldWzBdID0gbWF4KGRwW2ldWzBdLCBkcFtqXVsxXSArIDEpOwogICAgICAgICAgICBpZihhW2pdIDwgYVtpXSkgZHBbaV1bMV0gPSBtYXgoZHBbaV1bMV0sIGRwW2pdWzBdICsgMSk7CiAgICAgICAgfQogICAgfQogICAgY291dCA8PCBuIC0gbWF4KGRwW24gLSAxXVswXSwgZHBbbiAtIDFdWzFdKSA8PCBlbmRsOwogICAgcmV0dXJuIDA7Cn0=