import sys



def solve():

    n = int(input())

    A = [int(i) for i in input().split()]



    flag = 0

    l = 0

    r = 0

    cnt = 0



    while r < n - 1:

        if A[r] == A[r + 1]:

            r += 1

        elif A[r] < A[r + 1]:

            if flag == 2:

                cnt += 1

                flag = 0

                l = r + 1

                r = l

            else:

                flag = 1

                r += 1

        else:

            if flag == 1:

                cnt += 1

                flag = 0

                l = r + 1

                r = l

            else:

                flag = 2

                r += 1



    cnt += 1



    print(cnt)



def debug(x, table):

    for name, val in table.items():

        if x is val:

            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)

            return None



if __name__ == '__main__':

    solve()

import sys



def solve():

    n = int(eval(input()))

    a = [int(i) for i in input().split()]



    ans = 0



    mode = 0



    for i in range(1, n):

        if a[i] > a[i - 1]:

            if mode == -1:

                ans += 1

                mode = 0

            else:

                mode = 1

        elif a[i] < a[i - 1]:

            if mode == 1:

                ans += 1

                mode = 0

            else:

                mode = -1

        else:

            pass



    ans += 1



    print(ans)



if __name__ == '__main__':

    solve()
import sys


def solve():
    n = int(input())
    A = [int(i) for i in input().split()]
    flag = 0
    l = 0
    r = 0
    cnt = 0
    while r < n - 1:
        if A[r] == A[r + 1]:
            r += 1
        elif A[r] < A[r + 1]:
            if flag == 2:
                cnt += 1
                flag = 0
                l = r + 1
                r = l
            else:
                flag = 1
                r += 1
        else:
            if flag == 1:
                cnt += 1
                flag = 0
                l = r + 1
                r = l
            else:
                flag = 2
                r += 1
    cnt += 1
    print(cnt)


def debug(x, table):
    for name, val in table.items():
        if x is val:
            print("DEBUG:{} -> {}".format(name, val), file=sys.stderr)
            return None


if __name__ == "__main__":
    solve()

import sys


def solve():
    n = int(eval(input()))
    a = [int(i) for i in input().split()]
    ans = 0
    mode = 0
    for i in range(1, n):
        if a[i] > a[i - 1]:
            if mode == -1:
                ans += 1
                mode = 0
            else:
                mode = 1
        elif a[i] < a[i - 1]:
            if mode == 1:
                ans += 1
                mode = 0
            else:
                mode = -1
        else:
            pass
    ans += 1
    print(ans)


if __name__ == "__main__":
    solve()

-    n = int(input()) -    A = [int(i) for i in input().split()] -    flag = 0 -    l = 0 -    r = 0 -    cnt = 0 -    while r < n - 1: -        if A[r] == A[r + 1]: -            r += 1 -        elif A[r] < A[r + 1]: -            if flag == 2: -                cnt += 1 -                flag = 0 -                l = r + 1 -                r = l +    n = int(eval(input())) +    a = [int(i) for i in input().split()] +    ans = 0 +    mode = 0 +    for i in range(1, n): +        if a[i] > a[i - 1]: +            if mode == -1: +                ans += 1 +                mode = 0 -                flag = 1 -                r += 1 +                mode = 1 +        elif a[i] < a[i - 1]: +            if mode == 1: +                ans += 1 +                mode = 0 +            else: +                mode = -1 -            if flag == 1: -                cnt += 1 -                flag = 0 -                l = r + 1 -                r = l -            else: -                flag = 2 -                r += 1 -    cnt += 1 -    print(cnt) - - -def debug(x, table): -    for name, val in table.items(): -        if x is val: -            print("DEBUG:{} -> {}".format(name, val), file=sys.stderr) -            return None +            pass +    ans += 1 +    print(ans)