import scala.annotation.tailrec
import scala.collection.mutable
object Main extends App {
  import scala.io.StdIn._
  val l = readInt()
  val history = readLine.trim.split(' ').map(_.toInt).toList
  println(search(history))
  @tailrec def search(history: List[Int], isIn: Array[Boolean] = Array.fill(101){false}, stack: List[Int] = Nil, count: Int = 1): String = {
    history match {
      case Nil ⇒ "OK"
      case h::t if h > 0 ⇒
        if (isIn(h)) count.toString
        else {
          isIn(h) = true
          search(t, isIn, h::stack, count + 1)
        }
      case h::t ⇒
        if (!isIn(-h)) count.toString
        else {
          stack match {
            case s::r if s == -h ⇒
              isIn(s) = false
              search(t, isIn, r, count + 1)
            case _ ⇒ count.toString
          }
        }
    }
  }
}

