n=int(eval(input()))

a=list(map(int,input().split()))

b=[]

c=[]

if n==1:

        print((1))



else:

    for i in range(n-1):

            if a[i]!=a[i+1]:

                    b.append(a[i])



    b.append(a[n-1])

    ans=1



    for i in range(len(b)-1):

            c.append(b[i+1]-b[i])



    d=c[0]

    for i in range(1,len(b)-1):

            if d*c[i]>=0:

                    d=c[i]

            else:

                    ans+=1

                    d=0

    print(ans)





#参考(傾きの捉え方)

N = int(eval(input()))

A = list(map(int, input().split()))

f = 0

c = 1

i = 0

while i < N-1:

    if f == 0:

        if A[i] < A[i+1]:

            f = 1

        elif A[i] > A[i+1]:

            f = -1

    elif f == 1:

        if A[i] > A[i+1]:

            c += 1

            f = 0

    elif f == -1:

        if A[i] < A[i+1]:

            c += 1

            f = 0

    i += 1

print(c)
n = int(eval(input()))
a = list(map(int, input().split()))
b = []
c = []
if n == 1:
    print((1))
else:
    for i in range(n - 1):
        if a[i] != a[i + 1]:
            b.append(a[i])
    b.append(a[n - 1])
    ans = 1
    for i in range(len(b) - 1):
        c.append(b[i + 1] - b[i])
    d = c[0]
    for i in range(1, len(b) - 1):
        if d * c[i] >= 0:
            d = c[i]
        else:
            ans += 1
            d = 0
    print(ans)

# 参考(傾きの捉え方)
N = int(eval(input()))
A = list(map(int, input().split()))
f = 0
c = 1
i = 0
while i < N - 1:
    if f == 0:
        if A[i] < A[i + 1]:
            f = 1
        elif A[i] > A[i + 1]:
            f = -1
    elif f == 1:
        if A[i] > A[i + 1]:
            c += 1
            f = 0
    elif f == -1:
        if A[i] < A[i + 1]:
            c += 1
            f = 0
    i += 1
print(c)

-n = int(eval(input())) -a = list(map(int, input().split())) -b = [] -c = [] -if n == 1: -    print((1)) -else: -    for i in range(n - 1): -        if a[i] != a[i + 1]: -            b.append(a[i]) -    b.append(a[n - 1]) -    ans = 1 -    for i in range(len(b) - 1): -        c.append(b[i + 1] - b[i]) -    d = c[0] -    for i in range(1, len(b) - 1): -        if d * c[i] >= 0: -            d = c[i] -        else: -            ans += 1 -            d = 0 -    print(ans) +# 参考(傾きの捉え方) +N = int(eval(input())) +A = list(map(int, input().split())) +f = 0 +c = 1 +i = 0 +while i < N - 1: +    if f == 0: +        if A[i] < A[i + 1]: +            f = 1 +        elif A[i] > A[i + 1]: +            f = -1 +    elif f == 1: +        if A[i] > A[i + 1]: +            c += 1 +            f = 0 +    elif f == -1: +        if A[i] < A[i + 1]: +            c += 1 +            f = 0 +    i += 1 +print(c)