import Foundation

// １行文字列
func readStr() -> String {
  readLine()!
}

// １行整数
func readInt() -> Int {
  Int(readLine()!)!
}

// 空白文字で分割された文字列
func readSpStrs() -> [String] {
  readLine()!.components(separatedBy: " ")
}

// 空白文字で分割された整数
func readSpInts() -> [Int] {
  readSpStrs().map { Int($0)! }
}

// N行分の整数
func readInt(_ n: Int) -> [Int] {
  (1...n).map { _ in readInt() }
}

struct S {
  var valCount: [Int: Int] = [:]
  mutating func append(_ i: Int) {
    valCount[i] = valCount[i, default: 0] + 1
  }
}


let nm = readSpInts()
var s = S()
(1...nm[1])
  .forEach { _ in readSpInts().forEach { s.append($0) } }
let kk = (1...nm[0])
  .map { s.valCount[$0, default: 0] }
  .filter { $0 <= 1 }
  .count
print(kk - 2)

