using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;

namespace 水色コーダーに俺はなる{
    class PriorityQueue<T> where T : IComparable<T>{
        private List<T> list = new List<T>();

        public long Count{
            get{
                return list.Count;
            }
        }

        public void Enqueue(T elem){
            int c = list.Count;
            list.Add(elem);

            while(c!=0){
                int i = (c-1) /2;

                if(list[c].CompareTo(list[i])>0){
                    T tmp = list[c];
                    list[c] = list[i];
                    list[i] = tmp;
                }
                
                c = i;
            }
        }

        public T Dequeue(){
            int c = list.Count - 1;
            T pop = list[0];
            list[0] = list[c];
            list.RemoveAt(c);

            for(int i=0, j=1; j<c; ){
                if((j != c-1) && (list[j].CompareTo(list[j+1]) < 0)){
                    j ++;
                }

                if(list[i].CompareTo(list[j])<0){
                    T tmp = list[j];
                    list[j] = list[i];
                    list[i] = tmp;
                }

                i = j;
                j = 2*i + 1;
            }

            return pop;
        }
    }
    class Inonoa{

        /* ここに書け */
        static void Main(){
            long[] nk = ILongs();
            long[] p = ILongs();

            SortedSet<long>ma = new SortedSet<long>();


            for(int i=0;i<nk[1];i++){
                ma.Add(p[i]);
            }
            long id = 0;

            long ans = 1;

            for(int i=1;i<nk[0]-nk[1]+1;i++){
                long mn = ma.Min;

                bool changed = false;

                if(p[i-1]!=mn){
                    changed = true;
                }

                ma.Remove(p[i-1]);

                ma.Add(p[i+nk[1]-1]);

                if(p[i+nk[1]-1]!=ma.Max){
                    changed = true;
                }

                if(changed)ans ++;

            }

            long nochage = 0;

            long syoujun = 1;
            for(int i=1;i<nk[0];i++){
                if(p[i]>p[i-1]){
                    syoujun++;
                    if(syoujun==nk[1]){
                        nochage ++;
                    }
                }else{
                    syoujun = 1;
                }
            }

            WriteLine(ans - Max(nochage-1,0));
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 33624