fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val r = readLine()!!.split(" ").map { it.toLong() }
    val fixed = mutableListOf(r.first())
    for(i in (1 until n)) {
        if(r[i] != fixed.last()) {
            fixed.add(r[i])
        }
    }
    var isBigger = true
    if(fixed.size >= 2) {
        isBigger = fixed[0] < fixed[1]
    }
    var ans = 1
    var idx = 1
    if(fixed.size >= 2) {
        while (idx < fixed.size) {
            if(isBigger) {
                if(fixed[idx-1] < fixed[idx]) {
                    idx++
                    continue
                }
            } else {
                if(fixed[idx-1] > fixed[idx]) {
                    idx++
                    continue
                }
            }
            if(idx < fixed.size - 1) {
                isBigger = fixed[idx] <= fixed[idx+1]
            }
            ans++
            idx+=1
        }
    }
    println(ans)
}