"use strict";

function main(input) {
  input = input.split("\n");
  let row = [];
  for (let i in input) {
    row[i] = input[i].split(" ");
  }
  let load = row.slice(2, row.length);
  let bigger = 0;

  for (let i = 1; i <= row[1].length; i++) {
    // 展望台
    let count = 0; // 道につながっていればカウントアップ
    for (let n in load) {
      // 道
      for (let m in load[n]) {
        if (load[n][m] == i) {
          count++;
          const reverse = Math.abs(m - 1);
          // console.log(
          //   `load: ${load[n]}, load-rev: ${load[n][reverse]} i: ${i}, m: ${m}`
          // );
          if (load[n][reverse] < row[1][i]) {
            bigger++;
          }
        }
      }
    }
    // console.log(`count: ${count}`);
    if (count == 0) {
      bigger++;
    }
  }
  // console.log(row);
  console.log(bigger);
}

main(require("fs").readFileSync("/dev/stdin", "utf-8"));
