# coding:utf-8





def inpl(): return list(map(int, input().split()))





N = int(eval(input()))

A = inpl()



ans = 1

prev = A[0]

state = 0  # 1: 増加, 0: 横ばい, -1: 減少

for i in range(1, N):

    if state == 0:

        if A[i] > prev:

            state = 1

        elif A[i] < prev:

            state = -1



    elif state == 1:

        if A[i] < prev:

            ans += 1

            state = 0



    else:

        if A[i] > prev:

            ans += 1

            state = 0



    prev = A[i]



print(ans)

# coding:utf-8



import sys

# from collections import Counter, defaultdict



INF = float('inf')

MOD = 10 ** 9 + 7



def LI(): return [int(x) for x in sys.stdin.readline().split()]

def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]

def LS(): return sys.stdin.readline().split()

def II(): return int(sys.stdin.readline())

def SI(): return eval(input())





def main():

    n = II()

    A = LI()



    # 1: 単調非減少，2: 単調非増加，0: 未定

    state = 0

    prev = A[0]

    res = 1

    for cur in A:

        if state:

            if state == 1 and prev > cur:

                res += 1

                state = 0

            if state == 2 and prev < cur:

                res += 1

                state = 0

        else:

            if prev < cur:

                state = 1

            if prev > cur:

                state = 2

        prev = cur



    return res





print((main()))

# coding:utf-8
def inpl():
    return list(map(int, input().split()))


N = int(eval(input()))
A = inpl()
ans = 1
prev = A[0]
state = 0  # 1: 増加, 0: 横ばい, -1: 減少
for i in range(1, N):
    if state == 0:
        if A[i] > prev:
            state = 1
        elif A[i] < prev:
            state = -1
    elif state == 1:
        if A[i] < prev:
            ans += 1
            state = 0
    else:
        if A[i] > prev:
            ans += 1
            state = 0
    prev = A[i]
print(ans)

# coding:utf-8
import sys

# from collections import Counter, defaultdict
INF = float("inf")
MOD = 10**9 + 7


def LI():
    return [int(x) for x in sys.stdin.readline().split()]


def LI_():
    return [int(x) - 1 for x in sys.stdin.readline().split()]


def LS():
    return sys.stdin.readline().split()


def II():
    return int(sys.stdin.readline())


def SI():
    return eval(input())


def main():
    n = II()
    A = LI()
    # 1: 単調非減少，2: 単調非増加，0: 未定
    state = 0
    prev = A[0]
    res = 1
    for cur in A:
        if state:
            if state == 1 and prev > cur:
                res += 1
                state = 0
            if state == 2 and prev < cur:
                res += 1
                state = 0
        else:
            if prev < cur:
                state = 1
            if prev > cur:
                state = 2
        prev = cur
    return res


print((main()))

-def inpl(): -    return list(map(int, input().split())) +import sys + +# from collections import Counter, defaultdict +INF = float("inf") +MOD = 10**9 + 7 -N = int(eval(input())) -A = inpl() -ans = 1 -prev = A[0] -state = 0  # 1: 増加, 0: 横ばい, -1: 減少 -for i in range(1, N): -    if state == 0: -        if A[i] > prev: -            state = 1 -        elif A[i] < prev: -            state = -1 -    elif state == 1: -        if A[i] < prev: -            ans += 1 -            state = 0 -    else: -        if A[i] > prev: -            ans += 1 -            state = 0 -    prev = A[i] -print(ans) +def LI(): +    return [int(x) for x in sys.stdin.readline().split()] + + +def LI_(): +    return [int(x) - 1 for x in sys.stdin.readline().split()] + + +def LS(): +    return sys.stdin.readline().split() + + +def II(): +    return int(sys.stdin.readline()) + + +def SI(): +    return eval(input()) + + +def main(): +    n = II() +    A = LI() +    # 1: 単調非減少，2: 単調非増加，0: 未定 +    state = 0 +    prev = A[0] +    res = 1 +    for cur in A: +        if state: +            if state == 1 and prev > cur: +                res += 1 +                state = 0 +            if state == 2 and prev < cur: +                res += 1 +                state = 0 +        else: +            if prev < cur: +                state = 1 +            if prev > cur: +                state = 2 +        prev = cur +    return res + + +print((main()))