from statistics import median

#import collections

#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]

from fractions import gcd

from itertools import combinations # (string,3) 3回

from collections import deque

from collections import defaultdict

import bisect

#

#    d = m - k[i] - k[j]

#    if kk[bisect.bisect_right(kk,d) - 1] == d:

#

#

#

# pythonで無理なときは、pypyでやると正解するかも！！

#

#



import sys

sys.setrecursionlimit(10000000)

mod = 10**9 + 7



def readInts():

  return list(map(int,input().split()))

def I():

  return int(eval(input()))

n = I()

A = readInts()

cnt = 0

i = 0

while i < n:

    # まず同じ値を処理する

    if i+1 < n:

        while A[i+1] == A[i]:

            i += 1

    # その次の者が大きい?

    if i+1 < n:

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

            while A[i] <= A[i+1]:

                i += 1

                if i+1 < n:

                    pass

                else:

                    break

        else:

            while A[i] >= A[i+1]:

                i += 1

                if i + 1 < n:

                    pass

                else:

                    break

    cnt += 1

    i += 1

print(cnt)

#from statistics import median

import collections

#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]

#from fractions import gcd

#from itertools import combinations # (string,3) 3回

#from collections import deque

#from collections import deque,defaultdict

#import bisect

#

#    d = m - k[i] - k[j]

#    if kk[bisect.bisect_right(kk,d) - 1] == d:

#

#

#

# pythonで無理なときは、pypyでやると正解するかも！！

#

#



import sys

sys.setrecursionlimit(10000000)

mod = 10**9 + 7

#mod = 9982443453

def readInts():

  return list(map(int,input().split()))

def I():

  return int(eval(input()))

n = I()

S = readInts()

i = 0

cnt = 0

while i < n:

    while i+1 < n:

        if S[i] == S[i+1]:

            i += 1

        else:

            break

    if i + 1 < n:

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

            while i + 1 < n:

                if S[i] <= S[i+1]:

                    i += 1

                else:

                    break

        else:

            while i + 1 < n:

                if S[i] >= S[i+1]:

                    i += 1

                else:

                    break

    cnt += 1

    i += 1

print(cnt)

from statistics import median

# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations  # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect

#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
import sys

sys.setrecursionlimit(10000000)
mod = 10**9 + 7


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


def I():
    return int(eval(input()))


n = I()
A = readInts()
cnt = 0
i = 0
while i < n:
    # まず同じ値を処理する
    if i + 1 < n:
        while A[i + 1] == A[i]:
            i += 1
    # その次の者が大きい?
    if i + 1 < n:
        if A[i] <= A[i + 1]:
            while A[i] <= A[i + 1]:
                i += 1
                if i + 1 < n:
                    pass
                else:
                    break
        else:
            while A[i] >= A[i + 1]:
                i += 1
                if i + 1 < n:
                    pass
                else:
                    break
    cnt += 1
    i += 1
print(cnt)

# from statistics import median
import collections

# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
# from fractions import gcd
# from itertools import combinations # (string,3) 3回
# from collections import deque
# from collections import deque,defaultdict
# import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
import sys

sys.setrecursionlimit(10000000)
mod = 10**9 + 7
# mod = 9982443453
def readInts():
    return list(map(int, input().split()))


def I():
    return int(eval(input()))


n = I()
S = readInts()
i = 0
cnt = 0
while i < n:
    while i + 1 < n:
        if S[i] == S[i + 1]:
            i += 1
        else:
            break
    if i + 1 < n:
        if S[i] < S[i + 1]:
            while i + 1 < n:
                if S[i] <= S[i + 1]:
                    i += 1
                else:
                    break
        else:
            while i + 1 < n:
                if S[i] >= S[i + 1]:
                    i += 1
                else:
                    break
    cnt += 1
    i += 1
print(cnt)

-from statistics import median +# from statistics import median +import collections -# import collections -from fractions import gcd -from itertools import combinations  # (string,3) 3回 -from collections import deque -from collections import defaultdict -import bisect - +# from fractions import gcd +# from itertools import combinations # (string,3) 3回 +# from collections import deque +# from collections import deque,defaultdict +# import bisect - - +# mod = 9982443453 -A = readInts() +S = readInts() +i = 0 -i = 0 -    # まず同じ値を処理する +    while i + 1 < n: +        if S[i] == S[i + 1]: +            i += 1 +        else: +            break -        while A[i + 1] == A[i]: -            i += 1 -    # その次の者が大きい? -    if i + 1 < n: -        if A[i] <= A[i + 1]: -            while A[i] <= A[i + 1]: -                i += 1 -                if i + 1 < n: -                    pass +        if S[i] < S[i + 1]: +            while i + 1 < n: +                if S[i] <= S[i + 1]: +                    i += 1 -            while A[i] >= A[i + 1]: -                i += 1 -                if i + 1 < n: -                    pass +            while i + 1 < n: +                if S[i] >= S[i + 1]: +                    i += 1