"use strict";
const input = require("fs").readFileSync("/dev/stdin", "utf8");
const inputs = input.trim().split("\n");
 
const min = arr => {
  let m = null;
  for (const a of arr) {
    if (a < m || m === null) {
      m = a;
    }
  }
  return m;
}

const get = (inputs) => {
  const As = inputs.slice(1);
  
  const colors = [];
  let colorsMin = null;
  let colorNow = 0;
  let colorOldIndex = null;
  
  for (const A of As) {
    const a = +A;
    
    if (!(colorNow < a)) {
      if (colorOldIndex !== null && colorOldIndex !== -1) {
        colors.splice(colorOldIndex, 1);
        if (colors[colorOldIndex] === colorsMin) {
          colorsMin = min(colors);
        }
      }
      colors.push(colorNow);
      colorsMin = colorNow;
      let broke = false;
      if (colorsMin < a) {
        for (let i = colors.length-1; i >= 0; i--) {
          if (colors[i] < a) {
            colorOldIndex = i
            broke = true;
            break;
          }
        }
        if (broke) colorOldIndex = -1;
      }
    }
    colorNow = a;
  }
  if (As[As.length-2] < +As[As.length-1]) {
    colors.push(colorNow)
  }
  
  return colors.length
}
 
console.log( get(inputs) );