package main import ( "bufio" "fmt" "os" "strconv" "strings" _ "math" _ "sort" ) func main() { //scanner := bufio.NewScanner(os.Stdin) N := 0 fmt.Scan(&N) srcs := []int{} scanner := bufio.NewScanner(os.Stdin) for scanner.Scan() { for _, x := range strings.Split(scanner.Text(), " ") { x2, _ := strconv.Atoi(x) srcs = append(srcs, x2) } break } diff := 0 for i := len(srcs) - 1; i >= 0; i-- { if srcs[i] == N - diff { diff += 1 } } fmt.Println(N - diff) }