//Заготовка от Влада(4)
import java.io.*;
import java.util.*;
//import java.lang.*;
//import java.math.*;
public class solution{
	static StringTokenizer st;
	static BufferedReader br;
	static PrintWriter pw;
	static class Que_Elems implements Comparable<Que_Elems> {
		int id;
		int nextId;
		@Override
		public int compareTo(Que_Elems o) {
			return -(this.nextId-o.nextId);
		}
		public Que_Elems(int id, int nextId) {
			this.id = id;
			this.nextId = nextId;
		}
	}
	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int n = nextInt();
		int k = nextInt();
		int[]a = new int[n];
		int[]next = new int[n];
		int[]last = new int[n+1];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		Arrays.fill(last, n);
		for (int i = n-1; i >= 0; i--) {
			next[i] = last[a[i]];
			last[a[i]] = i;
		}
		int ans = 0;
		PriorityQueue<Que_Elems> q = new PriorityQueue<>();
		Set<Integer> inLibrary = new TreeSet<>();
		for (int i = 0; i < n; i++) {
			if (!inLibrary.contains(a[i])) {
				ans++;
				if (inLibrary.size()==k) {
					int whatBook = q.poll().id;
					inLibrary.remove(a[whatBook]);
				}
				q.add(new Que_Elems(i, next[i]));
				inLibrary.add(a[i]);
			}
			else
				q.add(new Que_Elems(i, next[i]));
		}
		System.out.println(ans);
		pw.close();
	}
	private static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	private static long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	private static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
	private static String next() throws IOException {
		while (st==null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class B {

	static StringTokenizer st;
	static BufferedReader br;
	static PrintWriter pw;
	static class Que_Elems implements Comparable<Que_Elems> {
		int id;
		int nextId;
		@Override
		public int compareTo(Que_Elems o) {
			return -(this.nextId-o.nextId);
		}
		public Que_Elems(int id, int nextId) {
			this.id = id;
			this.nextId = nextId;
		}
	}
	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int n = nextInt();
		int k = nextInt();
		int[]a = new int[n];
		int[]next = new int[n];
		int[]last = new int[n+1];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		Arrays.fill(last, n);
		for (int i = n-1; i >= 0; i--) {
			next[i] = last[a[i]];
			last[a[i]] = i;
		}
		int ans = 0;
		PriorityQueue<Que_Elems> q = new PriorityQueue<>();
		Set<Integer> inLibrary = new TreeSet<>();
		for (int i = 0; i < n; i++) {
			if (!inLibrary.contains(a[i])) {
				ans++;
				if (inLibrary.size()==k) {
					int whatBook = q.poll().id;
					inLibrary.remove(a[whatBook]);
				}
				q.add(new Que_Elems(i, next[i]));
				inLibrary.add(a[i]);
			}
			else
				q.add(new Que_Elems(i, next[i]));
		}
		System.out.println(ans);
		pw.close();
	}
	private static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	private static long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	private static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
	private static String next() throws IOException {
		while (st==null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class cdfhelvetic2017a
{
	static void merge(int arr[], int l, int m, int r)
    {
        int n1 = m - l + 1;
        int n2 = r - m;
        int L[] = new int [n1];
        int R[] = new int [n2];
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];
        int i = 0, j = 0;
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }
    static void sort(int arr[], int l, int r)
    {
        if (l < r)
        {
            int m = (l+r)/2;
            sort(arr, l, m);
            sort(arr , m+1, r);
            merge(arr, l, m, r);
        }
    }
    static int gcd(int a, int b)
    {
      if (b == 0)
        return a;
      return gcd(b, a % b);
    }
    static long power(long n,long m)
    {
    	if(m==0)
    		return 1;
    	long ans=1;
    	while(m>0)
    	{
    		ans=ans*n;
    		m--;
    	}
    	return ans;
    }
    static int binarySearch(int arr[], int x)
    {
        int l = 0, r = arr.length - 1;
        while (l <= r) {
            int m = l + (r - l) / 2;
            if (arr[m] == x)
                return m;
            if (arr[m] < x)
                l = m + 1;
            else
                r = m - 1;
        }
        return -1;
    }
	public static void main(String args[])throws Exception
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=1;//Integer.parseInt(br.readLine());
		for(int i=0;i<t;i++)
		{
			String s=br.readLine();
			String str[]=s.split(" ");
			int n=Integer.parseInt(str[0]);
			int cap=Integer.parseInt(str[1]);
			int a[]=new int[cap];//for the books in library
			int b[]=new int[n+1];//for the books taken
			int arr[]=new int[n];//day wala sab hisaab kitaab
			s=br.readLine();
			int tempo=0;
			String ss[]=s.split(" ");
			int dis=0,dis1=0,tt=0;
			for(int j=0;j<n;j++)
			{
				arr[j]=Integer.parseInt(ss[j]);
				if(tempo<cap&&b[arr[j]]==0)
				{
					a[tempo]=arr[j];
					tempo++;
					b[arr[j]]=1;
					dis++;
					dis1++;
					tt=j;
				}
				else if(b[arr[j]]==0)
					dis++;
			}
			if(dis<=cap)
			{
				System.out.println(dis);
				return;
			}
			int cost=dis1;
//			System.out.println(cost);
//			for(int k=0;k<cap;k++)
//			System.out.print(a[k]+" ");
//			System.out.println();
			out1:for(int j=tt;j<n;j++)
			{
				for(int k=0;k<cap;k++)
				{
					if(a[k]==arr[j])
					continue out1;
				}
				int k=0,l=j,pos=-1;
				int temp1[]=new int[cap];
				outer:for(k=0;k<cap;k++)
				{
					for(l=j;l<n;l++)
					{
						if(a[k]==arr[l])
						{
							temp1[k]=l;
							continue outer;
						}
					}
					pos=k;
					break;
				}
				//System.out.println("pos= "+pos);
				if(pos>=0)
				a[pos]=arr[j];
				else
				{
					int min=temp1[0],pos1=0;
					for(k=0;k<cap;k++)
					{
						//System.out.print(temp1[k]+" ");
						if(temp1[k]>min)
						{
							min=temp1[k];
							pos1=k;
						}
					}
					//System.out.println("pos1= "+pos1+" elem= "+arr[j]+" elem1= "+a[pos1]);
					a[pos1]=arr[j];
				}
				cost++;
			}
			System.out.println(cost);
		}
	}
}

import java.util.*;
import java.io.*;
import java.math.*;
public class hc {
	InputStream is;
	PrintWriter out;
	static class Pair implements Comparable<Pair>{

        int x,y,k,i;

	Pair (int x,int y){
		this.x=x;
		this.y=y;
	}

	public int compareTo(Pair o) {
			if(this.x!=o.x)
				return	this.x-o.x;
			else
				return 	this.y-o.y;
	}

        public boolean equals(Object o) {
            if (o instanceof Pair) {
                Pair p = (Pair)o;
                return p.x == x && p.y == y && p.k==k;
            }
            return false;
        }

        @Override
        public String toString() {
            return  "("+x + " " + y +" "+k+" "+i+" )";
        }

    }
	long mod=pow(10,9)+7;
	static boolean prime[];
	static ArrayList<Integer> al[];
	static int max=100000;
	void solve()
	{
		int n=ni();
		int k=ni();
		int a[]=na(n);
		ArrayList<Integer> current=new ArrayList<Integer>();
		int cost=0;
		for(int i=0;i<n;i++)
		{
			if(!current.contains((Integer)a[i]))
			{
				if(current.size()<k)
				{
					current.add(a[i]);
				}
				else
				{
					int maxindex=0,maxbook=0;
				outer:	for(int j=0;j<current.size();j++)
					{
						for(int l=i+1;l<n;l++)
						{
							if(current.get(j)==a[l])
							{
								if(l>maxindex)
								{
									maxindex=l;
									maxbook=a[l];
								}
								continue outer;
							}
						}
						maxindex=Integer.MAX_VALUE;
						maxbook=current.get(j);
					}
					current.remove((Integer)maxbook);
					current.add(a[i]);
				}
				cost++;
			}
		}
		out.println(cost);
	}
	public static void dev()
	{
		al=new ArrayList[max+1];
		for(int i=0;i<=max;i++)
			al[i]=new ArrayList<Integer>();
		for(int i=1;i<=max;i++)
		{
			for(int j=i;j<=max;j+=i)
				al[j].add(i);
		}
	}
	public static void prime(int n)
	{

		prime=new boolean[n+1];
		int count=0;
		for(int i=2;i*i<=n;i++)
		{
			if(prime[i])
				continue;
			for(int j=i;j*i<=n;j++)
			{
				prime[i*j]=true;
			}
		}
	}

	public static int count(int num)
	{
		int count=0;
		while(num!=0)
		{
			num=num&(num-1);
			count++;
		}
		return count;
	}
	/*static long d, x, y;
	void extendedEuclid(long A, long B) {
	    if(B == 0) {
	        d = A;
	        x = 1;
	        y = 0;
	    }
	    else {
	        extendedEuclid(B, A%B);
	        long temp = x;
	        x = y;
	        y = temp - (A/B)*y;
	    }
	}
	long modInverse(long A,long M) //A and M are coprime
	{
	    extendedEuclid(A,M);
	    return (x%M+M)%M;    //x may be negative
	}*/
	public static void mergeSort(int[] arr, int l ,int r){
		if((r-l)>=1){
			int mid = (l+r)/2;
			mergeSort(arr,l,mid);
			mergeSort(arr,mid+1,r);
			merge(arr,l,r,mid);
		}
	}
	public static void merge(int arr[], int l, int r, int mid){
		int n1 = (mid-l+1), n2 = (r-mid);
		int left[] = new int[n1];
		int right[] = new int[n2];
		for(int i =0 ;i<n1;i++) left[i] = arr[l+i];
		for(int i =0 ;i<n2;i++) right[i] = arr[mid+1+i];
		int i =0, j =0, k = l;
		while(i<n1 && j<n2){
			if(left[i]>right[j]){
				arr[k++] = right[j++];
			}
			else{
				arr[k++] = left[i++];
			}
		}
		while(i<n1) arr[k++] = left[i++];
		while(j<n2) arr[k++] = right[j++];
	}
	public static void mergeSort(long[] arr, int l ,int r){
		if((r-l)>=1){
			int mid = (l+r)/2;
			mergeSort(arr,l,mid);
			mergeSort(arr,mid+1,r);
			merge(arr,l,r,mid);
		}
	}
	public static void merge(long arr[], int l, int r, int mid){
		int n1 = (mid-l+1), n2 = (r-mid);
		long left[] = new long[n1];
		long right[] = new long[n2];
		for(int i =0 ;i<n1;i++) left[i] = arr[l+i];
		for(int i =0 ;i<n2;i++) right[i] = arr[mid+1+i];
		int i =0, j =0, k = l;
		while(i<n1 && j<n2){
			if(left[i]>right[j]){
				arr[k++] = right[j++];
			}
			else{
				arr[k++] = left[i++];
			}
		}
		while(i<n1) arr[k++] = left[i++];
		while(j<n2) arr[k++] = right[j++];
	}

	    public static boolean isPal(String s){
	        for(int i=0, j=s.length()-1;i<=j;i++,j--){
	                if(s.charAt(i)!=s.charAt(j)) return false;
	        }
	        return true;
	    }
	    public static String rev(String s){
			StringBuilder sb=new StringBuilder(s);
			sb.reverse();
			return sb.toString();
	    }

	    public static long gcd(long x,long y){
		if(x%y==0)
			return y;
		else
			return gcd(y,x%y);
	    }

	    public static int gcd(int x,int y){
		if(x%y==0)
			return y;
		else
			return gcd(y,x%y);
	    }

	    public static long gcdExtended(long a,long b,long[] x){

	        if(a==0){
	            x[0]=0;
	            x[1]=1;
	            return b;
	        }
	        long[] y=new long[2];
	        long gcd=gcdExtended(b%a, a, y);

	        x[0]=y[1]-(b/a)*y[0];
	        x[1]=y[0];

	        return gcd;
	    }

	    public static int abs(int a,int b){
		return (int)Math.abs(a-b);
	    }

	    public static long abs(long a,long b){
		return (long)Math.abs(a-b);
	    }

	    public static int max(int a,int b){
		if(a>b)
			return a;
		else
			return b;
	    }

	    public static int min(int a,int b){
		if(a>b)
			return b;
		else
			return a;
	    }

	    public static long max(long a,long b){
		if(a>b)
			return a;
		else
			return b;
	    }

	    public static long min(long a,long b){
		if(a>b)
			return b;
		else
			return a;
	    }

	    public static long pow(long n,long p,long m){
		 long  result = 1;
		  if(p==0)
		    return 1;
		if (p==1)
		    return n;
		while(p!=0)
		{
		    if(p%2==1)
		        result *= n;
		    if(result>=m)
		    result%=m;
		    p >>=1;
		    n*=n;
		    if(n>=m)
		    n%=m;
		}
		return result;
	    }

	    public static long pow(long n,long p){
		long  result = 1;
		  if(p==0)
		    return 1;
		if (p==1)
		    return n;
		while(p!=0)
		{
		    if(p%2==1)
		        result *= n;
		    p >>=1;
		    n*=n;
		}
		return result;
	    }
	    public static void debug(Object... o) {
			System.out.println(Arrays.deepToString(o));
		}
	    void run() throws Exception {
			is = System.in;
			out = new PrintWriter(System.out);
			solve();
			out.flush();
		}

	    public static void main(String[] args) throws Exception {
			new Thread(null, new Runnable() {
				public void run() {
					try {
						new hc().run();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}, "1", 1 << 26).start();
		}
	    private byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		private int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b));
			return b;
		}

		private double nd() {
			return Double.parseDouble(ns());
		}

		private char nc() {
			return (char) skip();
		}

		private String ns() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		private char[] ns(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		private char[][] nm(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = ns(m);
			return map;
		}

		private int[] na(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = ni();
			return a;
		}

		private int ni() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		private long nl() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}
}

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author da_201612051
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    FastIO in = new FastIO(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskA1 solver = new TaskA1();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskA1 {

    public void solve(int testNumber, FastIO in, PrintWriter out) {
      int n = in.nextInt();
      int k = in.nextInt();
      int[] query = in.nextIntArray(n);
      int cost = 0;
      Set<Integer> availableBooks = new HashSet<>(k);
      int[] access = new int[81];
      int removable = -1;
      for (int i = 0; i < n; i++) {
        access[query[i]]++;
      }
      for (int i = 0; i < n; i++) {
        int currentBook = query[i];
        boolean doesNotContain = !availableBooks.contains(currentBook);
        if (doesNotContain) {
          cost++;
        }
        if (removable != -1) {
          availableBooks.remove(removable);
          removable = -1;
        } else if (availableBooks.size() == k && doesNotContain) {
          int removableBook = -1;
          int count = k;
          Set<Integer> known = new HashSet<>();
          for (int j = i + 1; j < n && count > 0; j++) {
            if (availableBooks.contains(query[j]) && !known.contains(query[j])) {
              count--;
              known.add(query[j]);
              removableBook = query[j];
            }
          }
          if (removableBook != -1) {
            availableBooks.remove(removableBook);
          } else {
            availableBooks.remove(availableBooks.iterator().next());
          }
        }
        availableBooks.add(currentBook);
        if (--access[currentBook] == 0) {
          removable = currentBook;
        }
      }
      out.println(cost);
    }

  }

  static class FastIO {

    final private int BUFFER_SIZE = 1 << 16;
    private InputStream din;
    private byte[] buffer;
    private int bufferPointer;
    private int bytesRead;

    public FastIO() {
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
    }

    public FastIO(InputStream inputStream) {
      this();
      din = new DataInputStream(inputStream);
    }

    public FastIO(String file_name) {
      try {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      }
    }

    public int nextInt() {
      int ret = 0;
      try {
        byte c = read();
        while (c <= ' ') {
          c = read();
        }
        boolean neg = (c == '-');
        if (neg) {
          c = read();
        }
        do {
          ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');

        if (neg) {
          return -ret;
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
      return ret;
    }

    public int[] nextIntArray(int n) {
      int[] arr = new int[n];
      for (int i = 0; i < n; i++) {
        arr[i] = nextInt();
      }
      return arr;
    }

    private void fillBuffer() {
      try {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1) {
          buffer[0] = -1;
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    private byte read() {
      if (bufferPointer == bytesRead) {
        fillBuffer();
      }
      return buffer[bufferPointer++];
    }

  }
}

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author da_201612051
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    FastIO in = new FastIO(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskA1 solver = new TaskA1();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskA1 {

    public void solve(int testNumber, FastIO in, PrintWriter out) {
      int n = in.nextInt();
      int k = in.nextInt();
      int[] query = in.nextIntArray(n);
      int cost = 0;
      Set<Integer> availableBooks = new HashSet<>(k);
      int[] access = new int[81];
      int removable = -1;
      Arrays.stream(query).forEach(book -> access[book]++);
      for (int i = 0; i < n; i++) {
        int currentBook = query[i];
        boolean doesNotContain = !availableBooks.contains(currentBook);
        if (doesNotContain) {
          cost++;
        }
        if (removable != -1) {
          availableBooks.remove(removable);
          removable = -1;
        } else if (availableBooks.size() == k && doesNotContain) {
          int removableBook = -1;
          int count = k;
          Set<Integer> known = new HashSet<>();
          for (int j = i + 1; j < n && count > 0; j++) {
            if (availableBooks.contains(query[j]) && !known.contains(query[j])) {
              count--;
              known.add(query[j]);
              removableBook = query[j];
            }
          }
          if (removableBook != -1) {
            availableBooks.remove(removableBook);
          } else {
            availableBooks.remove(availableBooks.iterator().next());
          }
        }
        availableBooks.add(currentBook);
        if (--access[currentBook] == 0) {
          removable = currentBook;
        }
      }
      out.println(cost);
    }

  }

  static class FastIO {

    final private int BUFFER_SIZE = 1 << 16;
    private InputStream din;
    private byte[] buffer;
    private int bufferPointer;
    private int bytesRead;

    public FastIO() {
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
    }

    public FastIO(InputStream inputStream) {
      this();
      din = new DataInputStream(inputStream);
    }

    public FastIO(String file_name) {
      try {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      }
    }

    public int nextInt() {
      int ret = 0;
      try {
        byte c = read();
        while (c <= ' ') {
          c = read();
        }
        boolean neg = (c == '-');
        if (neg) {
          c = read();
        }
        do {
          ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');

        if (neg) {
          return -ret;
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
      return ret;
    }

    public int[] nextIntArray(int n) {
      int[] arr = new int[n];
      for (int i = 0; i < n; i++) {
        arr[i] = nextInt();
      }
      return arr;
    }

    private void fillBuffer() {
      try {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1) {
          buffer[0] = -1;
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    private byte read() {
      if (bufferPointer == bytesRead) {
        fillBuffer();
      }
      return buffer[bufferPointer++];
    }

  }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            TreeSet<Integer> books = new TreeSet<>();
            int ans = 0;
            for (int i = 0; i < n; i++) {
                if (!books.contains(a[i])) {
                    ans++;
                    if (books.size() < k) {
                        books.add(a[i]);
                    } else {
                        int unused = 0;
                        int unusedTime = 0;
                        for (int book : books) {
                            loop:
                            {
                                for (int j = i; j < n; j++) {
                                    if (a[j] == book) {
                                        if (j - i > unusedTime) {
                                            unusedTime = j - i;
                                            unused = book;
                                        }
                                        break loop;
                                    }
                                }
                                unused = book;
                                unusedTime = n;
                            }
                        }
                        books.remove(unused);
                        books.add(a[i]);
                    }
                }
            }
            out.println(ans);
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.util.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;

public class Main implements Runnable{

	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars==-1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}

				if(numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine()
		{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
		}
		public int nextInt()
		{
			int c = read();

			while(isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;
			do
			{
				if(c<'0'||c>'9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			long res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));
				return res * sgn;
		}

		public double nextDouble()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.')
			{
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.')
			{
				c = read();
				double m = 1;
				while (!isSpaceChar(c))
				{
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public String readString()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = read();
			}
			while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next()
		{
			return readString();
		}

		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}
	}
	static LinkedList <Integer> adj[];

    static void Check2(int n){
        adj=new LinkedList[n+1];
        for(int i=0;i<=n;i++){
            adj[i]=new LinkedList();
        }

    }
    static void add(int i,int j){
       // if(!adj[i].contains(j))
        adj[i].add(j);
   // if(!adj[j].contains(i))
        adj[j].add(i);

     //   adj[j].add(i);

    }
	  public static void main(String[] args) throws Exception {
    new Thread(null, new Main(), "Check2", 1<<26).start();// to increse stack size in java
  }
    static int flag2=1;
    static int ne=0;
  public void run(){
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        //Scanner in=new Scanner(System.in);
    InputReader in=new InputReader(System.in);
		PrintWriter w=new PrintWriter(System.out);

   int n=in.nextInt();

      int k=in.nextInt();

      int a[]=new int[n];
      for(int i=0;i<n;i++)
      {
          a[i]=in.nextInt();
      }

   if(k>=n){
       HashMap <Integer,Integer> map=new HashMap();
          for(int i=0;i<n;i++){

              map.put(a[i],1);
             // cost++;
          }

       w.println(map.size());
   }
      else{

          int cost=0;

          HashMap <Integer,Integer> map=new HashMap();
          for(int i=0;i<k;i++){

              map.put(a[i],1);
             // cost++;
          }

          cost=map.size();
          for(int i=k;i<n;i++)
          {

              int f[]=new int[n+1];
                      HashMap <Integer,Integer> map2=new HashMap();
  if(map.containsKey(a[i])){
      continue;
  }
              else if(map.size()<k){

                  map.put(a[i],i);
                  cost++;
                  continue;
              }

              int flag=0;

             for (Map.Entry<Integer,Integer> entry : map.entrySet()) {
     Integer key = entry.getKey();

                for(int j=i+1;j<n;j++){
                    if(a[j]==key){
                        flag=1;
                        if(!map2.containsKey(a[j]))
                        map2.put(a[j],j);
                    }
                }

                if(!map2.containsKey(key)){
                    map2.put(key,1000);
                }

             }
              if(flag==1){
                  int max=0;
                  int id=-1;
                       for (Map.Entry<Integer,Integer> entry : map2.entrySet()) {
     Integer key = entry.getKey();
                           int val=entry.getValue();

              //     System.out.println(key+" "+val);
                           if(val>max){
                               max=val;
                               id=key;
                           }

                       }
      //            System.out.println(id+" "+i);
                  map.remove(id);
                  cost++;
              }
              else{

                  int id=-1;
                       for (Map.Entry<Integer,Integer> entry : map2.entrySet()) {
     Integer key = entry.getKey();
                           id=key;
                           break;
                           //int val=entry.getValue();
                       }
                  map.remove(id);

                  cost++;

              }

              map.put(a[i],i);

              }

          w.println(cost);

      }

        w.close();

    }
    static class node{

        int y;
        int val;

        node(int a,int b){

            y=a;
            val=b;

        }

    }

}

import java.util.Scanner;
import java.util.Arrays;
import java.io.PrintWriter;

public class Main
{
        private static final Scanner in=new Scanner(System.in);
        private static final PrintWriter out=new PrintWriter(System.out);

	public static void main (String[] args) throws java.lang.Exception
	{
		int n=in.nextInt(), k=in.nextInt(), a[]=new int[n], b[]=new int[n], books=0;

                Arrays.fill(b,0);
                for(int i=0;i<n;i++) {
                 a[i]=in.nextInt()-1;
                }
                in.close();

                int counter=0;
                for(int i=0;i<n;i++) {
                 if(b[a[i]]==0) {
                   ++books; ++counter;
                   if(counter>k) {
                    int least=check(a,b,i);
                    //System.out.printf("%d %d %d\n",i,least, a[least]+1);
                    b[a[least]]=0;
                    counter-=1;
                   }
                   b[a[i]]=1;
                 }
                }

                out.print(books);
                out.close();
        }

        private static int check(int a[], int b[], int n) {
         int max=-1000, pos=-1, mpos=-1; boolean x;
         for(int i=0;i<a.length;i++) {
          if(b[a[i]]==1) {
           x=false; int j=n+1;
           for(;j<a.length;j++) {
             if(a[i]==a[j]) {
              x=!x;
              if(max<(j-n)) max=(j-n);
              //System.out.println("max of "+(a[i]+1)+"="+max+"and pos="+pos);
              pos=j; if(mpos<pos) mpos=pos;
              break;
             }
           }
           if(!x) {
              //System.out.println("executed");
            return i;
           }
         }
        }
        return mpos;
       }

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            int k = in.readInt();
            int[] a = IOUtils.readIntArray(in, n);
            MiscUtils.decreaseByOne(a);
            HashSet<Integer> library = new HashSet<>();
            int res = 0;
            for (int want = 0; want < n; want++) {
                if (library.contains(a[want])) continue;
                res++;
                if (library.size() == k) {
                    int other = -1, far = -1;
                    for (int book : library) {
                        int dist = n;
                        for (int i = want + 1; i < n; i++) {
                            if (a[i] == book) {
                                dist = i;
                                break;
                            }
                        }
                        if (dist > far) {
                            far = dist;
                            other = book;
                        }
                    }
                    library.remove(other);
                }
                library.add(a[want]);
            }
            out.printLine(res);
        }
    }
    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(int i) {
            writer.println(i);
        }
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
    static class IOUtils {
        public static int[] readIntArray(InputReader in, int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++) {
                array[i] = in.readInt();
            }
            return array;
        }
    }
    static class MiscUtils {
        public static void decreaseByOne(int[]... arrays) {
            for (int[] array : arrays) {
                for (int i = 0; i < array.length; i++) {
                    array[i]--;
                }
            }
        }
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            int k = in.readInt();
            int[] a = IOUtils.readIntArray(in, n);
            MiscUtils.decreaseByOne(a);
            int[] containsBook = new int[n];
            Arrays.fill(containsBook, -1);
            TreeSet<IntIntPair> byNext = new TreeSet<>(); // nxt, book
            int[] nextIndex = new int[n];
            {
                int[] indexOf = new int[n];
                Arrays.fill(indexOf, n);
                for (int i = nextIndex.length - 1; i >= 0; i--) {
                    nextIndex[i] = indexOf[a[i]];
                    indexOf[a[i]] = i;
                }
            }
            int res = 0;
            for (int want = 0; want < n; want++) {
                int book = a[want];
                if (containsBook[book] != -1) {
                    if (!byNext.remove(new IntIntPair(containsBook[book], book))) throw new RuntimeException();
                    containsBook[book] = nextIndex[want];
                    byNext.add(new IntIntPair(nextIndex[want], book));
                    continue;
                }
                res++;
                if (byNext.size() == k) {
                    IntIntPair toRemove = byNext.pollLast();
                    containsBook[toRemove.second] = -1;
                }
                containsBook[book] = nextIndex[want];
                byNext.add(new IntIntPair(nextIndex[want], book));
            }
            out.printLine(res);
        }
    }
    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(int i) {
            writer.println(i);
        }
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
    static class IOUtils {
        public static int[] readIntArray(InputReader in, int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++) {
                array[i] = in.readInt();
            }
            return array;
        }
    }
    static class IntIntPair implements Comparable<IntIntPair> {
        public final int first;
        public final int second;

        public IntIntPair(int first, int second) {
            this.first = first;
            this.second = second;
        }

        public boolean equals(Object o) {
            if (this == o) {
                return true;
            }
            if (o == null || getClass() != o.getClass()) {
                return false;
            }
            IntIntPair pair = (IntIntPair) o;
            return first == pair.first && second == pair.second;
        }

        public int hashCode() {
            int result = first;
            result = 31 * result + second;
            return result;
        }

        public String toString() {
            return "(" + first + "," + second + ")";
        }

        @SuppressWarnings ({"unchecked"})
        public int compareTo(IntIntPair o) {
            int value = Integer.compare(first, o.first);
            if (value != 0) {
                return value;
            }
            return Integer.compare(second, o.second);
        }
    }
    static class MiscUtils {
        public static void decreaseByOne(int[]... arrays) {
            for (int[] array : arrays) {
                for (int i = 0; i < array.length; i++) {
                    array[i]--;
                }
            }
        }
    }
}

import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int k = sc.nextInt();

		List<Integer> lib = new LinkedList<Integer>();
		int costs = 0;
		int[] requests = new int[N];

		for(int i = 0; i < N; i++) {
			requests[i] = sc.nextInt();
		}

		for(int i = 0; i < N ; i++) {
			if(lib.contains(requests[i])) {
				continue;
			}
			if(lib.size() == k) {
				toDiscard(lib, i, requests);
			}
			lib.add(requests[i]);
			costs++;
		}

		System.out.println(costs);
		sc.close();
	}

	static void toDiscard(List<Integer> lib, int from, int[] requests) {
		List<Integer> copy_lib = new LinkedList<Integer>();
		copy_lib.addAll(lib);

		for(int i = from; i < requests.length; i++) {
			if(copy_lib.size() <= 1) {
				break;
			}
			if(copy_lib.contains(requests[i])) {
				copy_lib.remove((Object)requests[i]);
			}
		}
		lib.remove(copy_lib.get(0));
	}

}

// CodeForces Round #815 A TODO
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class  HeidiLibrary {

	int n,k;
	int []a;
	int []lib;
	int minCost;

	private void readData(BufferedReader bin) throws IOException {
		String s = bin.readLine();
		String[] ss = s.split(" ");
		// read x,y,l,r
		n = Integer.parseInt(ss[0]);
		k = Integer.parseInt(ss[1]);
		// read a
		s = bin.readLine();
		ss = s.split(" ");
		a = new int[n];
		for (int i=0; i<n; i++) {
			a[i] = Integer.parseInt(ss[i]);
		}
	}

	void printRes() {
		System.out.println(minCost);
	}

	/**
	 * check if we have book in library, so we don't have to buy it
	 * @param lib - library array like [1, 3, 5]
	 * @param book - book like 3
	 * @return - true if we have book, false if not
	 */
	boolean haveBook(int book) {
		boolean have=false;
		for (int i=0; i<lib.length; i++) {
			if (book==lib[i]) {
				have = true;
			}
		}
		return have;
	}

	/**
	 * when book will be needed next time
	 * @return
	 */
	int nextUse(int book, int aIdx) {
		int nu = 1000000;
		for (int i=aIdx+1; i<n; i++) {
			if (book == a[i]) {
				nu = i;
				break;
			}
		}
		return nu;
	}

	/** replace least useful book in library by book */
	void addBook(int book, int aIdx) {
		int nu, lastUse = -1000000;
		int idxLastUse = 0;
		// looking book with largest nextUse to throw away
		for (int i=0; i<lib.length; i++) {
			nu = nextUse(lib[i], aIdx);
			if (nu > lastUse) {
				lastUse = nu;
				idxLastUse = i;
			}
		}
		// replacing book
		// System.out.println("replaced " + lib[idxLastUse] + " with " + book);
		lib[idxLastUse] = book;
	}

	private void calculate() {
		lib = new int[k];
		for (int i=0; i<n; i++) {
			if (!haveBook(a[i])) {
				minCost++;
				addBook(a[i], i);
			}
		}
	}

	public static void main(String[] args) throws IOException {
		// BufferedReader bin = new BufferedReader(new FileReader("cactus.in"));
		BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
		HeidiLibrary l = new HeidiLibrary();
		l.readData(bin);
		l.calculate();
		l.printRes();
	}
}

import java.util.*;
import java.io.*;
  public class Task {

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static Map<Integer,List<Integer>> map=new HashMap<>();
static int[] f;
  public static void main(String args[]) throws  IOException {
        assign();
        int[] n1=int_arr();
        int n=n1[0],k=n1[1],res=0;
        int[] b=int_arr();
        f=new int[n+1];
        for(int i=0;i<n;i++){
            map.computeIfAbsent(b[i],k1->new ArrayList<>()).add(i);
        }
        Set<Integer> s=new HashSet<>();
        for(int i=0;i<n;i++){
            if(s.contains(b[i])){
                f[b[i]]++;
                continue;
            }
            if(s.size()<k){
                s.add(b[i]);
                f[b[i]]++;res++;
            }
            else{
                int tmp=-1,rr=-1;
                for(int xx:s){
                    if(map.get(xx).size()<=f[xx]){
                        rr=xx;break;
                    }
                    if(map.get(xx).get(f[xx])>tmp){
                        rr=xx;
                        tmp=map.get(xx).get(f[xx]);
                    }
                }
                s.remove(rr);
                s.add(b[i]);
                f[b[i]]++;res++;
            }
        }

        out.write(res+"\n");

             out.flush();
    }

}

import java.util.*;
import java.io.*;
  public class Task {

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static Map<Integer,List<Integer>> map=new HashMap<>();

static int cmp(int[] a, int[] b){
    if(map.get(b[0]).size()<=b[1]+1){return 1;}
    if(map.get(a[0]).size()<=a[1]+1){return -1;}
    return map.get(b[0]).get(b[1]+1)-map.get(a[0]).get(a[1]+1);
}
  public static void main(String args[]) throws  IOException {
        assign();
        int[] n1=int_arr();
        int n=n1[0],k=n1[1],res=0;
        int[] b=int_arr();
        int[] f=new int[n+1];
        for(int i=0;i<n;i++){
            map.computeIfAbsent(b[i],k1->new ArrayList<>()).add(i);
        }
        Set<Integer> s=new HashSet<>();
        PriorityQueue<int[]> pq=new PriorityQueue<>((a,b1)->cmp(a,b1));
        for(int i=0;i<n;i++){
            if(s.contains(b[i])){
                 pq.remove(new int[]{b[i],f[b[i]]});
                 pq.add(new int[]{b[i],f[b[i]]});
                  f[b[i]]++;
                continue;
            }
            if(s.size()<k){
                pq.add(new int[]{b[i],f[b[i]]});
                f[b[i]]++;res++;
            }
            else{
                int[] z=pq.poll();
                pq.add(new int[]{b[i],f[b[i]]});
                f[b[i]]++;res++;
                s.remove(z[0]);
            }
            s.add(b[i]);
        }

        out.write(res+"\n");

             out.flush();
    }

}

import java.util.*;
import java.io.*;
  public class Task {

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static Map<Integer,List<Integer>> map=new HashMap<>();
static int[] f;
/*static int cmp(int[] a, int[] b){
    //return b[1]-a[1];

}*/
static int cmp(int a, int b){
    return map.get(b).get(f[b])-map.get(a).get(f[a]);
}
  public static void main(String args[]) throws  IOException {
        assign();
        int[] n1=int_arr();
        int n=n1[0],k=n1[1],res=0;
        int[] b=int_arr();
        f=new int[n+1];
        for(int i=0;i<n;i++){
            map.computeIfAbsent(b[i],k1->new ArrayList<>()).add(i);
        }
        for(int x:map.keySet()){
            map.get(x).add(1000000);
        }
        boolean[] have=new boolean[n+1];
        PriorityQueue<Integer> s1=new PriorityQueue<>((a,b1)-> cmp(a,b1));
        for(int i=0;i<n;i++){
            if(have[b[i]]){
                s1.remove(b[i]);
            }

            else{
                res++;
                if(s1.size()==k){have[s1.poll()]=false;}
            }

            f[b[i]]++;
            s1.add(b[i]);
            have[b[i]]=true;
        }

        out.write(res+"\n");
             out.flush();
    }

}

/*import java.util.*;
import java.io.*;
  public class Task {

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static Map<Integer,List<Integer>> map=new HashMap<>();
static int[] f;

static int cmp(int a, int b){
    return map.get(b).get(f[b])-map.get(a).get(f[a]);
}
  public static void main(String args[]) throws  IOException {
        assign();
        int[] n1=int_arr();
        int n=n1[0],k=n1[1],res=0;
        int[] b=int_arr();
        f=new int[n+1];
        for(int i=0;i<n;i++){
            map.computeIfAbsent(b[i],k1->new ArrayList<>()).add(i);
        }
        for(int x:map.keySet()){
            map.get(x).add(1000000);
        }
       // boolean[] have=new boolean[n+1];
        Set<Integer> s=new HashSet<>();
        PriorityQueue<Integer> s1=new PriorityQueue<>((a,b1)-> cmp(a,b1));
        for(int i=0;i<n;i++){
            if(s.contains(b[i])){
                s1.remove(b[i]);
                f[b[i]]++;
                s1.add(b[i]);
                continue;
            }
             if(s1.size()<k){
                f[b[i]]++;res++;
                s1.add(b[i]);
            }
            else{
                s.remove(s1.poll());
                f[b[i]]++;res++;
                s1.add(b[i]);

            }
            //have[b[i]]=true;
        }

        out.write(res+"\n");
             out.flush();
    }

}
*/

import java.util.*;
import java.io.*;
  public class Task {

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static Map<Integer,List<Integer>> map=new HashMap<>();

static int cmp(int[] a, int[] b){
    if(map.get(b[0]).size()<=b[1]+1){return 1;}
    if(map.get(a[0]).size()<=a[1]+1){return -1;}
    return map.get(b[0]).get(b[1]+1)-map.get(a[0]).get(a[1]+1);
}
  public static void main(String args[]) throws  IOException {
        assign();
        int[] n1=int_arr();
        int n=n1[0],k=n1[1],res=0;
        int[] b=int_arr();
        int[] f=new int[n+1];
        for(int i=0;i<n;i++){
            map.computeIfAbsent(b[i],k1->new ArrayList<>()).add(i);
        }
        Set<Integer> s=new HashSet<>();
        PriorityQueue<int[]> pq=new PriorityQueue<>((a,b1)->cmp(a,b1));
        for(int i=0;i<n;i++){
            if(s.contains(b[i])){
                 pq.remove(new int[]{b[i],f[b[i]]-1});
                 pq.add(new int[]{b[i],f[b[i]]});
                  f[b[i]]++;
                continue;
            }
            if(s.size()<k){
                pq.add(new int[]{b[i],f[b[i]]});
                f[b[i]]++;res++;
            }
            else{
                int[] z=pq.poll();
                pq.add(new int[]{b[i],f[b[i]]});
                f[b[i]]++;res++;
                s.remove(z[0]);
            }
            s.add(b[i]);
        }

        out.write(res+"\n");

             out.flush();
    }

}

import java.util.*;
import java.io.*;
  public class Task {

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static Map<Integer,List<Integer>> map=new HashMap<>();
static int[] f;
static int cmp(int[] a, int[] b){
    return b[1]-a[1];
}
  public static void main(String args[]) throws  IOException {
        assign();
        int[] n1=int_arr();
        int n=n1[0],k=n1[1],res=0;
        int[] b=int_arr();
        f=new int[n+1];
        for(int i=0;i<n;i++){
            map.computeIfAbsent(b[i],k1->new ArrayList<>()).add(i);
        }
        for(int x:map.keySet()){
            map.get(x).add(1000000);
        }
        boolean[] have=new boolean[n+1];
        TreeSet<int[]> s1=new TreeSet<>((a,b1)-> cmp(a,b1));
        for(int i=0;i<n;i++){
            if(have[b[i]]){
                s1.remove(new int[]{b[i],map.get(b[i]).get(f[b[i]])});
            }
            else{
                res++;
                if(s1.size()==k){have[s1.pollFirst()[0]]=false;}
            }

            f[b[i]]++;
            s1.add(new int[]{b[i],map.get(b[i]).get(f[b[i]])});
            have[b[i]]=true;
        }

        out.write(res+"\n");
             out.flush();
    }

}

import java.io.*;
import java.util.*;

public class h {
    public static void main (String[] args) {
        FastScanner s = new FastScanner();

        int n = s.nextInt(), k = s.nextInt();
        t = new int[n];
        for(int i = 0; i < n; i++) {
            int x = s.nextInt();
            t[i] = x;
        }

        boolean[] have = new boolean[500500];
        int res = 0;
        int[] comp = compress(t);
        int[] next = new int[comp.length];
        int[] last = new int[500500];
        Arrays.fill(last, 1000000);

        for(int i = comp.length-1; i >= 0; i--) {
            next[i] = last[comp[i]];
            last[comp[i]] = i;
        }

        PriorityQueue<Obj> pq = new PriorityQueue<>();
        res = 0;
        int cap = 0;
        have = new boolean[500500];
        for(int i = 0; i < comp.length; i++) {
            while (!pq.isEmpty() && pq.peek().pos < i) pq.poll();
            if(cap < k) {
                if(!have[comp[i]]) {
                    have[comp[i]] = true;
                    res++;
                    cap++;
                }
            } else {
                if(!have[comp[i]]) {
                    have[comp[i]] = true;
                    res++;
                    if (!pq.isEmpty()) {
                        have[pq.poll().num] = false;
                    }
                }
            }
            pq.add(new Obj(comp[i], next[i]));
        }

        System.out.println(res);

    }

    static class Obj implements Comparable<Obj> {
        int num;
        int pos;
        Obj (int a, int b) {num = a; pos = b;}

        @Override
        public int compareTo(Obj o) {
            return Integer.compare(o.pos, pos);
        }
    }

    static int[] compress(int[] a) {
        ArrayList<Integer> l = new ArrayList<>();
        int last = -1;
        for(int i = 0; i < a.length; i++) {
            if(last == a[i]) continue;
            last = a[i];
            l.add(a[i]);
        }
        int[] res = new int[l.size()];
        for(int i= 0; i < res.length; i++) res[i] = l.get(i);
        return res;
    }

    static int[] t;

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
//                br = new BufferedReader(new FileReader("testdata.out"));
                st = new StringTokenizer("");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String line = "";
            try {
                line = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return line;
        }

        public Integer[] nextIntegerArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        public char[] nextCharArray() {
            return nextLine().toCharArray();
        }
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public boolean contains(Set s, int[] a, int x) {
            Iterator it = s.iterator();
            while (it.hasNext()) {
                int v = (int) it.next();
                if (a[v] == a[x]) {
                    s.remove(v);
                    s.add(x);
                    return true;
                }
            }
            return false;
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int a[] = new int[n + 100];
            Set s = new TreeSet();
            int next[] = new int[200];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            for (int i = 0; i < 150; i++) {
                next[i] = -1;
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < i; j++) {
                    if (a[j] == a[i] && next[j] == -1) {
                        next[j] = i;
                    }
                }
            }
            for (int i = 0; i < n; i++) {
                if (next[i] == -1) next[i] = 150;
            }
            int ans = 0;
            for (int i = 0; i < n; i++) {
                //duyet(s);
                if (s.size() < k) {
                    if (contains(s, a, i)) continue;
                    else {
                        s.add(i);
                        ans++;
                    }
                } else {
                    if (contains(s, a, i)) continue;
                    else {
                        Iterator it = s.iterator();
                        int max = 0;
                        int loai = -1;
                        while (it.hasNext()) {
                            int x = (int) it.next();
                            if (next[x] > max) {
                                max = next[x];
                                loai = x;
                            }
                        }
                        s.remove(loai);
                        s.add(i);
                        ans++;
                    }
                }
            }
            out.print(ans);
        }

    }
}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * #
 *
 * @author pttrung
 */
public class A_Helvetic_2017_Easy {

	public static long MOD = 1000000007;

	public static void main(String[] args) throws FileNotFoundException {
		// PrintWriter out = new PrintWriter(new FileOutputStream(new File(
		// "output.txt")));
		PrintWriter out = new PrintWriter(System.out);
		Scanner in = new Scanner();
		int n = in.nextInt();
		int k = in.nextInt();
		int[] data = new int[n];
		for (int i = 0; i < n; i++) {
			data[i] = in.nextInt() - 1;
		}
		boolean[] check = new boolean[n];
		int[] last = new int[n];
		Arrays.fill(last, -1);
		int[][] next = new int[n][n];
		for (int i = n - 1; i >= 0; i--) {
			for (int j = 0; j < n; j++) {
				next[i][j] = last[j];
			}
			last[data[i]] = i;
		}
		int count = 0;
		int result = 0;
		for (int i = 0; i < n; i++) {
			if (!check[data[i]]) {
				if (count < k) {
					count++;
				} else {
					int max = -1;
					for (int j = 0; j < n; j++) {
						if (check[j]) {
							// if (i == 2)
							// System.out.println(j + " " + next[i][j]);
							if (max == -1 || (next[i][max] != -1 && next[i][max] < next[i][j]) || next[i][j] == -1) {
								max = j;
							}
						}
					}
					// System.out.println(i + " " + max + " " + next[i][max]);
					check[max] = false;
				}
				result++;
				check[data[i]] = true;
			}
		}
		out.println(result);

		out.close();
	}

	public static int[] KMP(String val) {
		int i = 0;
		int j = -1;
		int[] result = new int[val.length() + 1];
		result[0] = -1;
		while (i < val.length()) {
			while (j >= 0 && val.charAt(j) != val.charAt(i)) {
				j = result[j];
			}
			j++;
			i++;
			result[i] = j;
		}
		return result;

	}

	public static boolean nextPer(int[] data) {
		int i = data.length - 1;
		while (i > 0 && data[i] < data[i - 1]) {
			i--;
		}
		if (i == 0) {
			return false;
		}
		int j = data.length - 1;
		while (data[j] < data[i - 1]) {
			j--;
		}
		int temp = data[i - 1];
		data[i - 1] = data[j];
		data[j] = temp;
		Arrays.sort(data, i, data.length);
		return true;
	}

	public static int digit(long n) {
		int result = 0;
		while (n > 0) {
			n /= 10;
			result++;
		}
		return result;
	}

	public static double dist(long a, long b, long x, long y) {
		double val = (b - a) * (b - a) + (x - y) * (x - y);
		val = Math.sqrt(val);
		double other = x * x + a * a;
		other = Math.sqrt(other);
		return val + other;

	}

	public static class Point implements Comparable<Point> {

		int x, y;

		public Point(int start, int end) {
			this.x = start;
			this.y = end;
		}

		@Override
		public int hashCode() {
			int hash = 5;
			hash = 47 * hash + this.x;
			hash = 47 * hash + this.y;
			return hash;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			final Point other = (Point) obj;
			if (this.x != other.x) {
				return false;
			}
			if (this.y != other.y) {
				return false;
			}
			return true;
		}

		@Override
		public int compareTo(Point o) {
			return Integer.compare(x, o.x);
		}
	}

	public static class FT {

		long[] data;

		FT(int n) {
			data = new long[n];
		}

		public void update(int index, long value) {
			while (index < data.length) {
				data[index] += value;
				index += (index & (-index));
			}
		}

		public long get(int index) {
			long result = 0;
			while (index > 0) {
				result += data[index];
				index -= (index & (-index));
			}
			return result;

		}
	}

	public static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	public static long pow(long a, long b) {
		if (b == 0) {
			return 1;
		}
		if (b == 1) {
			return a;
		}
		long val = pow(a, b / 2);
		if (b % 2 == 0) {
			return val * val % MOD;
		} else {
			return val * (val * a % MOD) % MOD;

		}
	}

	static class Scanner {

		BufferedReader br;
		StringTokenizer st;

		public Scanner() throws FileNotFoundException {
			// System.setOut(new PrintStream(new
			// BufferedOutputStream(System.out), true));
			br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new
			// FileInputStream(new File("input.txt"))));
		}

		public String next() {

			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					throw new RuntimeException();
				}
			}
			return st.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			st = null;
			try {
				return br.readLine();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}

		public boolean endLine() {
			try {
				String next = br.readLine();
				while (next != null && next.trim().isEmpty()) {
					next = br.readLine();
				}
				if (next == null) {
					return true;
				}
				st = new StringTokenizer(next);
				return st.hasMoreTokens();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}
	}
}

import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n=in.nextInt(),k=in.nextInt(),out=0;
		Vector<Integer> books = new Vector<Integer>(),p=new Vector<Integer>();
		for (;n>0;n--) {
			p.add(in.nextInt());
		}
		while (!p.isEmpty()) {
			if (!books.contains(p.elementAt(0))) {
				out++;
				books.add(p.elementAt(0));
				if (books.size()>k) {
					@SuppressWarnings("unchecked")
					Vector<Integer> use = (Vector<Integer>) books.clone();
					int last=0;
					for (int z:p) {
						if (use.contains(z)) {
							use.removeElement(z);
							last = z;
						}
					}
					if (use.isEmpty()) {
						books.removeElement(last);
					} else {
						books.remove(use.elementAt(use.size()-1));
					}
				}
			}
			p.removeElementAt(0);
		}
		System.out.println(out);
		in.close();
 	}
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.lang.StringBuilder;
import java.util.*;
import java.lang.Math;

public class CFHelveticA {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = scanner.nextInt();
        int k = scanner.nextInt();

        int[] a = new int[n];
        for (int ii = 0; ii < n; ii++) a[ii] = scanner.nextInt();

        int ans = 0;
        ArrayList<Integer> books = new ArrayList<Integer>();
        for (int ii = 0; ii < n; ii++) {
            if (!books.contains(a[ii])) {
                if (books.size() >= k) {
                    int jjfar = -1;
                    int jjfardist = -1;
                    for (int jj = 0; jj < books.size(); jj++) {
                        int kk = ii;
                        while (kk < n && books.get(jj) != a[kk]) kk++;
                        if (jjfar == -1 || kk > jjfardist) {
                            jjfar = jj;
                            jjfardist = kk;
                        }
                    }
                    books.remove(jjfar);
                }
                books.add(a[ii]);
                ans++;
            }
        }

        writer.write(ans + "\n");
        writer.flush();
    }
}

import java.io.*;
import java.util.*;

public class h {
    public static void main (String[] args) {
        Scanner s = new Scanner(System.in);

        int n = s.nextInt(), k = s.nextInt();
        Book[] a = new Book[n];
        freq = new int[100];
        next = new int[100];

        Arrays.fill(next, 100100);
        t = new int[n];

        for(int i = 0; i < n; i++) {
            int x = s.nextInt();
            t[i] = x;
            freq[x]++;
            next[x] = i;
        }

        for(int i  =0; i < n; i++) a[i] = new Book(t[i], freq[t[i]]);

        int res = 0;
        ArrayList<Book> list = new ArrayList<>();

        boolean[] have = new boolean[100];
        int cap = 0;
        for(int i = 0; i < n; i++) {
            pos = i;
            if(cap < k) {
                if(!have[t[i]]) {
                    have[t[i]] = true;
                    cap++;
                    res++;
                    list.add(a[i]);
                }
            } else {
//                    System.out.println("!");
                if(!have[t[i]]) {
                    Collections.sort(list);
                    Book rem = list.remove(0);
//                    System.out.println(rem.num);
                    have[rem.num] = false;
                    cap--;

                    have[t[i]] = true;
                    cap++;
                    list.add(a[i]);
                    res++;

                } else {

                }

            }
            freq[t[i]]--;
//            System.out.println("R "  + res);
//            System.out.println(Arrays.toString(Arrays.copyOfRange(have, 0, 4)));
        }

        System.out.println(res);

    }

    static int[] t;
    static int[] freq;
    static int[] next;
    static int pos = 0;

    static int comesNext (int[] a, int pos, int look) {
        for(int i = pos+1; i < a.length; i++) if(a[i] == look) return i;
        return 100100;
    }

    static class Book implements Comparable<Book> {
        int num, ft;
        Book(int x, int f) {
            num = x; ft = f;
        }
        public int compareTo(Book o) {
            int nextNum = comesNext(t, pos, num), nextONum = comesNext(t, pos, o.num);
//            System.out.println(num + " " + nextNum + "\n" + o.num + " " + nextONum);
            if(nextNum < nextONum) return 1;
            if(nextNum > nextONum) return -1;
            return 0;
        }
    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

/**
 *
 * @author Harsh Vardhan Kumar
 */
public class newMain1 {
    public static boolean eof = false ;
    static Set<Book> library ;
    static int k ;
    static int [] requirement ;
    public static void main(String[] args) {
        Reader in = new Reader(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), true) ;

        int n = in.nextInt() ;
        k  = in.nextInt() ;
        int chf = 0 ;
        library = new HashSet<>(k);

        requirement = new int[n+1] ;
        int[] bookre = new int[n] ;
        Arrays.fill(requirement, Integer.MAX_VALUE);
        for(int i =  0 ; i<n ; i++) {
            int bookno = in.nextInt() ;
            bookre[i] = bookno ;
            if(requirement[bookno]!=Integer.MAX_VALUE) {
                requirement[bookno]++ ;
            }
            else if(requirement[bookno]==Integer.MAX_VALUE) {
                requirement[bookno] = 1 ;
            }
        }

//        System.out.println(Arrays.toString(requirement));
//        System.out.println(Arrays.toString(bookre));
//
        for(int a = 0 ;  a<bookre.length ; a++) {
            //System.out.println("");
            Book book = new Book(bookre[a]) ;
            //System.out.println("book is );
//            System.out.println("library is "+library);
//            System.out.println("requirement is "+Arrays.toString(requirement));
//            System.out.println(Arrays.toString(bookre));
//            System.out.println("book is "+book.valuenumber);
//
            if(!library.contains(book)) {
                //System.out.println("not available "+book.valuenumber);
                if(!isPlaceAvailable()) {
                    Book removed = booktoberemoved(bookre, a) ;
                    //System.out.println("place is not available");
                  //  System.out.println("removed book is "+removed.valuenumber);
                    library.remove(removed) ;

                    //chf++ ;
                    //library.add(book);
                }
                chf++ ;
                library.add(book) ;
                //System.out.println("chf is "+chf);
            }
            requirement[book.valuenumber]-- ;

        }

        System.out.println(chf);

    }
    private static boolean isPlaceAvailable() {
        return library.size()<k ;
    }
    private static Book booktoberemoved(int[] bookre, int i) {

        Book r = null ;
        int max = 0 ;
        for(Book book : library) {
            //System.out.println("inside book is "+book);
            boolean found = false ;
            for(int j = i+1 ; j<requirement.length-1 ; j++) {
                if(book.valuenumber==bookre[j]) {
                //    System.out.println("found at "+j);
                  //  System.out.println("");
                    found = true ;
                    if(max<j) {
                        max = j;
                        r = book ;
                    }
                    break ;
                }
            }
            if(!found) {
                return book ;
            }

        }

        return r ;
    }
    static class Reader {
        private static BufferedReader b ;
        public static String line ;
        public Reader() {
        }

        public Reader(BufferedReader b) {
            this.b = b ;
        }
        private static StringTokenizer st = null;
        public static String next()  {

            if(st==null || !st.hasMoreElements()) {
                try {
                    line = b.readLine() ;
                    if(line==null) {
                        eof = true ;
                        return null ;
                    }
                    else {
                        st=new StringTokenizer(line);
                    }
                } catch (IOException ex) {

                }
            }
            return st.nextToken() ;
        }
        public static String nextLine()  {
            try {
                return b.readLine() ;
            } catch (IOException ex) {

            }
            return line ;
        }
        public static int nextInt()  {
            return Integer.parseInt(next());
        }
        public static long nextLong()  {
            return Long.parseLong(next());
        }
        public static float nextFloat()  {
            return Float.parseFloat(next());
        }
        public void close() throws IOException {
            b.close() ;
        }

    }
    static class Book {
        int valuenumber ;
        public String toString() {
            return valuenumber+" " ;
        }
        public Book(int valuenumber) {
            this.valuenumber = valuenumber;
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Book other = (Book) obj;
            if (this.valuenumber != other.valuenumber) {
                return false;
            }
            return true;
        }
        public int hashCode() {
            return valuenumber ;
        }
    }
}

import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        int[] a = new int[n];
        int[][] d = new int[n][n];
        for (int j = 0; j < n; j++)
        {
            a[j] = s.nextInt()-1;
            d[n - 1][j] = n;
        }
        for (int i = n - 1; i > 0; )
        {
            d[i][a[i]] = i;
            i--;
            d[i] = d[i + 1].clone();
            d[i][a[i]] = i;
        }
        int books = 0;
        boolean[] has = new boolean[n];
        int cost = 0;
        for (int i = 0; i < n; i++)
        {
            if (!has[a[i]]) // buy book a[i]
            {
            if(books == k) // eviction
            {
                int max = -1;
                int maxidx = 0;
                for (int j = 0; j < n; j++)
                {
                    if (has[j] && max < d[i][j])
                    {
                        max = d[i][j];
                        maxidx = j;
                    }
                }
                has[maxidx] = false;
                books--;
            }
                cost++;
                has[a[i]] = true;
                //System.out.printf("buy book %d%n",a[i]);
                books++;
            }
        }
        System.out.println(cost);
    }
}

import java.io.*;
import java.util.*;

public class QA802{

	static PrintWriter out = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s[] = in.readLine().split(" ");
		int n = Integer.parseInt(s[0]);
		int k = Integer.parseInt(s[1]);
		String s1[] = in.readLine().split(" ");
		TreeSet<Integer> a[] = new TreeSet[n+1];
		int b[] = new int[n];
		for(int i=0;i<=n;i++)
		{
			a[i] = new TreeSet<Integer>();
		}
		for(int i=0;i<n;i++)
		{
			b[i] = Integer.parseInt(s1[i]);
			a[b[i]].add(i);
		}
		HashSet<Integer> h = new HashSet<Integer>();
		int ans=0;
		for(int i=0;i<n;i++)
		{
			if(!h.contains(b[i]))
			{
				if(h.size()<k)
				{
					h.add(b[i]);
					ans++;
				}
				else
				{
					Iterator it = h.iterator();
					int max = Integer.MIN_VALUE,ind=-1;
					while(it.hasNext())
					{
						int x = (Integer)it.next();
						Object y = a[x].ceiling(i);
						if(y==null)
						{
							ind = x;
							break;
						}
						else
						{
							int l = (int)y;
							if(l==i)
							{
								ind=x;
								break;
							}
							if(l>i)
							{
								if(max<l)
								{
									max =l;
									ind = x;
								}
							}
						}
					}
					h.remove(ind);
					h.add(b[i]);
					ans++;
				}
			}
		}
		out.println(ans);
		out.close();
	}

}

import java.io.*;
import java.util.*;

public class TestClass {

	static PrintWriter out = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s[] = in.readLine().split(" ");
		int n = Integer.parseInt(s[0]);
		int k = Integer.parseInt(s[1]);
		String s1[] = in.readLine().split(" ");
		TreeSet<Integer> a[] = new TreeSet[n+1];
		int b[] = new int[n];
		for(int i=0;i<=n;i++)
		{
			a[i] = new TreeSet<Integer>();
		}
		for(int i=0;i<n;i++)
		{
			b[i] = Integer.parseInt(s1[i]);
			a[b[i]].add(i);
		}
		HashSet<Integer> h = new HashSet<Integer>();
		int ans=0;
		for(int i=0;i<n;i++)
		{
			if(!h.contains(b[i]))
			{
				if(h.size()<k)
				{
					h.add(b[i]);
					ans++;
				}
				else
				{
					Iterator it = h.iterator();
					int max = Integer.MIN_VALUE,ind=-1;
					while(it.hasNext())
					{
						int x = (Integer)it.next();
						Object y = a[x].ceiling(i);
						if(y==null)
						{
							ind = x;
							break;
						}
						else
						{
							int l = (int)y;
							if(l==i)
							{
								ind=x;
								break;
							}
							if(l>i)
							{
								if(max<l)
								{
									max =l;
									ind = x;
								}
							}
						}
					}
					h.remove(ind);
					h.add(b[i]);
					ans++;
				}
			}
		}
		out.println(ans);
		out.close();
	}

}

import java.util.Scanner;
import java.util.Arrays;

public class HeidiAndLibraryEasy {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();

		boolean[] cap = new boolean[n + 1];
		int[] books = new int[n + 1];
		int cost = 0;

		for (int ii = 1; ii <= n; ii++) {
			books[ii] = in.nextInt();
		}

		// System.out.println(Arrays.toString(booksCounter));

		for (int ii = 1; ii <= n; ii++) {
			int book = books[ii];

			// book not found
			if (cap[book] == false) {

				// check capacity
				// System.out.println("books counter: " + countBooks(cap));
				if (countBooks(cap) >= k) {
					// System.out.println(countBooks(cap) + "," + k);
					cap[findFarthestDemanded(cap, Arrays.copyOfRange(books, ii, books.length))] = false;
				}

				// buy book
				cost++;
				cap[book] = true;
				// System.out.println(Arrays.toString(cap));
			}
		}
		System.out.println(cost);
	}

	private static int findFarthestDemanded(boolean[] cap, int[] inBooks) {
		int[] demands = new int[cap.length];

		for (int ii = 1; ii < cap.length; ii++) {
			if (cap[ii] == false) continue;

			int firstDemandIdx = 999;
			for (int jj = 0; jj < inBooks.length; jj++) {
				if (ii == inBooks[jj]) {
					// System.out.println(jj);
					firstDemandIdx = jj;
					break;
				}
			}
			demands[ii] = firstDemandIdx;
		}

		// System.out.println(Arrays.toString(demands));

		int max = -1;
		for (int ii = 1; ii < demands.length; ii++) {
			if (max == -1 || demands[ii] > demands[max]) {
				max = ii;
			}
		}

		// System.out.println("bookToRemove: " + max);
		return max;
	}

	private static int countBooks(boolean[] cap) {
		int res = 0;
		for (int ii = 0; ii < cap.length; ii++) {
			if (cap[ii] == true) res++;
		}

		return res;
	}
}

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

public class Hiedi_and_library {
    public static void main(String[] a){
        Scanner sc=new Scanner(System.in);
      int n=sc.nextInt();
      int c=sc.nextInt();
      int cost=0;
      ArrayList ar=new ArrayList();
     ArrayList cr=new ArrayList();
      for(int i=0;i<n;i++){
      ar.add(sc.nextInt());
      }

      Iterator i=ar.listIterator();

      while(i.hasNext()){
          int v=(int)i.next();
      if(!cr.contains(v) && (cr.size()!=c)){
      cr.add(v);
      cost=cost+1;

      }
      else if(!cr.contains(v) && (cr.size()==c)){
      Iterator j=cr.listIterator();
      int max=0;
      int notexist=0;
      while(j.hasNext()){
          int t=(int)j.next();
          if((int)ar.indexOf(t)==-1){
          max=cr.indexOf(t);
          notexist=1;

          break;
          }
          if((int)ar.indexOf(t)>max  && ((int)ar.indexOf(t))!=-1){
      max=ar.indexOf(t);
              }
      }
     // int replace=(int)ar.get(max);

     if(max==0 || notexist==1){cr.set(max,v);
     cost=cost+1;

     }
     else{
      int index=cr.indexOf(ar.get(max));
      cr.set(index,v);
     cost=cost+1;}

      }
      i.remove();

      }
      System.out.println(cost);
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer buffer;

    public static void solve() {
        int n = ni();
        int k = ni();
        int[]a = ni(n);
        Set<Integer>books = new HashSet<>();

        int buys = 0;
        main:
        for (int i=0;i<n;i++) {
            if (books.contains(a[i])) continue;
            if (books.size()<k) {
                if (!books.contains(a[i])) {
                    buys++;
                    books.add(a[i]);
                }
            } else {
                buys++;
                int max = -1;
                for (Integer book: books) {
                    boolean found = false;
                    for (int j=i+1;j<n;j++) {
                        if (a[j]==book) {
                            max = Math.max(max, j);
                            found = true;
                            break;
                        }
                    }
                    if(!found) {
                        books.remove(book);
                        books.add(a[i]);
                        continue main;
                    }
                }

                books.remove(a[max]);
                books.add(a[i]);
            }
        }

        out.println(buys);
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    static String next() {
        while (buffer == null || !buffer.hasMoreElements()) {
            try {
                buffer = new StringTokenizer(in.readLine());
            } catch (IOException e) {
                //
            }
        }
        return buffer.nextToken();
    }

    static int ni() {
        return Integer.parseInt(next());
    }

    static long nl() {
        return Long.parseLong(next());
    }

    static double nd() {
        return Double.parseDouble(next());
    }

    static String ns() {
        return next();
    }

    static int[] ni(int n) {
        int[] res = new int[n];
        for (int i = 0; i < n; i++)
            res[i] = Integer.parseInt(next());
        return res;
    }

    static long[] nl(int n) {
        long[] res = new long[n];
        for (int i = 0; i < n; i++)
            res[i] = Long.parseLong(next());
        return res;
    }

    static double[] nd(int n) {
        double[] res = new double[n];
        for (int i = 0; i < n; i++)
            res[i] = Double.parseDouble(next());
        return res;
    }

    static String[] ns(int n) {
        String[] res = new String[n];
        for (int i = 0; i < n; i++)
            res[i] = next();
        return res;
    }

    static String nln() {
        try {
            return in.readLine();
        } catch (IOException e) {
            //
        }

        return null;
    }

}

import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Scanner;

public class B {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] A = new int[N];
    ArrayList<ArrayList<Integer>> next = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      A[i] = Integer.parseInt(sc.next()) - 1;
      next.add(new ArrayList<>());
      next.get(i).add(1 << 29);
    }
    for (int i = N - 1; i >= 0; i--) {
      next.get(A[i]).add(i);
    }
    PriorityQueue<Integer> q = new PriorityQueue<>((Integer i1, Integer i2) -> {
      ArrayList<Integer> l1 = next.get(i1);
      ArrayList<Integer> l2 = next.get(i2);
      return -Integer.compare(l1.get(l1.size() - 1), l2.get(l2.size() - 1));
    });

    int ans = 0;
    for (int i = 0; i < N; i++) {
      if (q.contains(A[i])) {
        q.remove(A[i]);
        next.get(A[i]).remove(next.get(A[i]).size() - 1);
        q.add(A[i]);
      } else {
        ++ans;
        next.get(A[i]).remove(next.get(A[i]).size() - 1);
        if (q.size() == K) {
          q.poll();
        }
        q.add(A[i]);
      }
    }
    System.out.println(ans);
  }

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.Random;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            int k = in.readInt();
            IntHashSet setA = new IntHashSet();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.readInt() - 1;
            }

            int answer = 0;
            for (int i = 0; i < n; i++) {
                if (!setA.contains(a[i])) {
                    ++answer;
                    if (setA.size() == k) {
                        int val = -1;
                        int maxFirstPosUse = -1;
                        for (Integer x : setA) {
                            int cur = n;
                            for (int j = i + 1; j < n; j++) {
                                if (x == a[j]) {
                                    cur = j;
                                    break;
                                }
                            }
                            if (maxFirstPosUse < cur) {
                                val = x;
                                maxFirstPosUse = cur;
                            }
                        }
                        if (val == -1) {
                            setA.remove(setA.first());
                        } else {
                            setA.remove(val);
                        }
                    }
                    setA.add(a[i]);
                }
            }
            out.printLine(answer);
        }

    }

    static interface IntStream extends Iterable<Integer>, Comparable<IntStream> {
        public IntIterator intIterator();

        default public Iterator<Integer> iterator() {
            return new Iterator<Integer>() {
                private IntIterator it = intIterator();

                public boolean hasNext() {
                    return it.isValid();
                }

                public Integer next() {
                    int result = it.value();
                    it.advance();
                    return result;
                }
            };
        }

        default public int first() {
            return intIterator().value();
        }

        default public int compareTo(IntStream c) {
            IntIterator it = intIterator();
            IntIterator jt = c.intIterator();
            while (it.isValid() && jt.isValid()) {
                int i = it.value();
                int j = jt.value();
                if (i < j) {
                    return -1;
                } else if (i > j) {
                    return 1;
                }
                it.advance();
                jt.advance();
            }
            if (it.isValid()) {
                return 1;
            }
            if (jt.isValid()) {
                return -1;
            }
            return 0;
        }

    }

    static interface IntIterator {
        public int value() throws NoSuchElementException;

        public boolean advance();

        public boolean isValid();

    }

    static interface IntCollection extends IntStream {
        public int size();

        default public void add(int value) {
            throw new UnsupportedOperationException();
        }

        default public IntCollection addAll(IntStream values) {
            for (IntIterator it = values.intIterator(); it.isValid(); it.advance()) {
                add(it.value());
            }
            return this;
        }

    }

    static class IntHashSet extends IntAbstractStream implements IntSet {
        private static final Random RND = new Random();
        private static final int[] SHIFTS = new int[4];
        private static final byte PRESENT_MASK = 1;
        private static final byte REMOVED_MASK = 2;
        private int size;
        private int realSize;
        private int[] values;
        private byte[] present;
        private int step;
        private int ratio;

        static {
            for (int i = 0; i < 4; i++) {
                SHIFTS[i] = RND.nextInt(31) + 1;
            }
        }

        public IntHashSet() {
            this(3);
        }

        public IntHashSet(int capacity) {
            capacity = Math.max(capacity, 3);
            values = new int[capacity];
            present = new byte[capacity];
            ratio = 2;
            initStep(capacity);
        }

        public IntHashSet(IntCollection c) {
            this(c.size());
            addAll(c);
        }

        public IntHashSet(int[] arr) {
            this(new IntArray(arr));
        }

        private void initStep(int capacity) {
            step = RND.nextInt(capacity - 2) + 1;
            while (IntegerUtils.gcd(step, capacity) != 1) {
                step++;
            }
        }

        public IntIterator intIterator() {
            return new IntIterator() {
                private int position = size == 0 ? values.length : -1;

                public int value() throws NoSuchElementException {
                    if (position == -1) {
                        advance();
                    }
                    if (position >= values.length) {
                        throw new NoSuchElementException();
                    }
                    if ((present[position] & PRESENT_MASK) == 0) {
                        throw new IllegalStateException();
                    }
                    return values[position];
                }

                public boolean advance() throws NoSuchElementException {
                    if (position >= values.length) {
                        throw new NoSuchElementException();
                    }
                    position++;
                    while (position < values.length && (present[position] & PRESENT_MASK) == 0) {
                        position++;
                    }
                    return isValid();
                }

                public boolean isValid() {
                    return position < values.length;
                }

                public void remove() {
                    if ((present[position] & PRESENT_MASK) == 0) {
                        throw new IllegalStateException();
                    }
                    present[position] = REMOVED_MASK;
                }
            };
        }

        public int size() {
            return size;
        }

        public void add(int value) {
            ensureCapacity((realSize + 1) * ratio + 2);
            int current = getHash(value);
            while (present[current] != 0) {
                if ((present[current] & PRESENT_MASK) != 0 && values[current] == value) {
                    return;
                }
                current += step;
                if (current >= values.length) {
                    current -= values.length;
                }
            }
            while ((present[current] & PRESENT_MASK) != 0) {
                current += step;
                if (current >= values.length) {
                    current -= values.length;
                }
            }
            if (present[current] == 0) {
                realSize++;
            }
            present[current] = PRESENT_MASK;
            values[current] = value;
            size++;
        }

        private int getHash(int value) {
            int hash = IntHash.hash(value);
            int result = hash;
            for (int i : SHIFTS) {
                result ^= hash >> i;
            }
            result %= values.length;
            if (result < 0) {
                result += values.length;
            }
            return result;
        }

        private void ensureCapacity(int capacity) {
            if (values.length < capacity) {
                capacity = Math.max(capacity * 2, values.length);
                rebuild(capacity);
            }
        }

        private void squish() {
            if (values.length > size * ratio * 2 + 10) {
                rebuild(size * ratio + 3);
            }
        }

        private void rebuild(int capacity) {
            initStep(capacity);
            int[] oldValues = values;
            byte[] oldPresent = present;
            values = new int[capacity];
            present = new byte[capacity];
            size = 0;
            realSize = 0;
            for (int i = 0; i < oldValues.length; i++) {
                if ((oldPresent[i] & PRESENT_MASK) == PRESENT_MASK) {
                    add(oldValues[i]);
                }
            }
        }

        public boolean remove(int value) {
            int current = getHash(value);
            while (present[current] != 0) {
                if (values[current] == value && (present[current] & PRESENT_MASK) != 0) {
                    present[current] = REMOVED_MASK;
                    size--;
                    squish();
                    return true;
                }
                current += step;
                if (current >= values.length) {
                    current -= values.length;
                }
            }
            return false;
        }

        public boolean contains(int value) {
            int current = getHash(value);
            while (present[current] != 0) {
                if (values[current] == value && (present[current] & PRESENT_MASK) != 0) {
                    return true;
                }
                current += step;
                if (current >= values.length) {
                    current -= values.length;
                }
            }
            return false;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(int i) {
            writer.println(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class IntHash {
        private IntHash() {
        }

        public static int hash(int c) {
            return c;
        }

    }

    static interface IntList extends IntReversableCollection {
        public abstract int get(int index);

        public abstract void addAt(int index, int value);

        public abstract void removeAt(int index);

        default public int first() {
            return get(0);
        }

        default public IntIterator intIterator() {
            return new IntIterator() {
                private int at;
                private boolean removed;

                public int value() {
                    if (removed) {
                        throw new IllegalStateException();
                    }
                    return get(at);
                }

                public boolean advance() {
                    at++;
                    removed = false;
                    return isValid();
                }

                public boolean isValid() {
                    return !removed && at < size();
                }

                public void remove() {
                    removeAt(at);
                    at--;
                    removed = true;
                }
            };
        }

        default public void add(int value) {
            addAt(size(), value);
        }

    }

    static abstract class IntAbstractStream implements IntStream {

        public String toString() {
            StringBuilder builder = new StringBuilder();
            boolean first = true;
            for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
                if (first) {
                    first = false;
                } else {
                    builder.append(' ');
                }
                builder.append(it.value());
            }
            return builder.toString();
        }

        public boolean equals(Object o) {
            if (!(o instanceof IntStream)) {
                return false;
            }
            IntStream c = (IntStream) o;
            IntIterator it = intIterator();
            IntIterator jt = c.intIterator();
            while (it.isValid() && jt.isValid()) {
                if (it.value() != jt.value()) {
                    return false;
                }
                it.advance();
                jt.advance();
            }
            return !it.isValid() && !jt.isValid();
        }

        public int hashCode() {
            int result = 0;
            for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
                result *= 31;
                result += it.value();
            }
            return result;
        }

    }

    static interface IntSet extends IntCollection {
    }

    static class IntArray extends IntAbstractStream implements IntList {
        private int[] data;

        public IntArray(int[] arr) {
            data = arr;
        }

        public int size() {
            return data.length;
        }

        public int get(int at) {
            return data[at];
        }

        public void addAt(int index, int value) {
            throw new UnsupportedOperationException();
        }

        public void removeAt(int index) {
            throw new UnsupportedOperationException();
        }

    }

    static interface IntReversableCollection extends IntCollection {
    }

    static class IntegerUtils {
        public static int gcd(int a, int b) {
            a = Math.abs(a);
            b = Math.abs(b);
            while (b != 0) {
                int temp = a % b;
                a = b;
                b = temp;
            }
            return a;
        }

    }
}

import java.util.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;

import static java.lang.Math.*;

public class Main implements Runnable
{
	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars==-1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}

				if(numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine()
		{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
		}
		public int nextInt()
		{
			int c = read();

			while(isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;
			do
			{
				if(c<'0'||c>'9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			long res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));
				return res * sgn;
		}

		public double nextDouble()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.')
			{
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.')
			{
				c = read();
				double m = 1;
				while (!isSpaceChar(c))
				{
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public String readString()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = read();
			}
			while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next()
		{
			return readString();
		}

		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}
	}

	static class Pair implements Comparable<Pair>
	{
		long k;
		long l;
		long f;

		public Pair(long k,long l)
		{
			this.k=k;
			this.l=l;

			f=min(2*k,l);
		}

		public int compareTo(Pair pair)
		{
			return Long.compare(f,pair.f);
		}
	}

	public static void main(String args[]) throws Exception
	{
		new Thread(null, new Main(),"Main",1<<26).start();
	}

	public void run()
	{
		InputReader sc= new InputReader(System.in);
		PrintWriter w= new PrintWriter(System.out);

		int n=sc.nextInt();

		int k=sc.nextInt();

		HashSet<Integer> set=new HashSet<Integer>();

		ArrayList<Integer> list=new ArrayList<Integer>();

		for(int i=0;i<n;i++)
			list.add(sc.nextInt());

		int cost=0;

		for(int i=0;i<n;i++)
		{
			int elem=list.get(i);

			if(set.contains(elem))
				continue;

			if(set.size()<k)
			{
				set.add(elem);
				cost++;
				continue;
			}

			int flag1=0;

			for(int in:set)
			{
				int flag=0;

				for(int j=i;j<n;j++)
				{
					if(list.get(j)==in)
						flag=1;
				}

				if(flag==0)
				{
					set.remove(in);
					set.add(elem);
					cost++;
					flag1=1;
					break;
				}
			}

			if(flag1==1)
				continue;

			HashSet<Integer> temp_set=new HashSet<Integer>();

			for(int in:set)
				temp_set.add(in);

			for(int j=i;j<n;j++)
			{
				if(temp_set.size()<=1)
					break;

				if(temp_set.contains(list.get(j)))
					temp_set.remove(list.get(j));
			}

			for(int in:temp_set)
				set.remove(in);

			cost++;
			set.add(elem);
		}

		w.println(cost);
		w.close();
	}
}

import java.util.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;

public class TestClass implements Runnable
{
	/*int x,y;
	public TestClass(int x,int y)
	{
		this.x=x;
		this.y=y;
	}*/
	public static void main(String args[]) throws Exception
	{
		new Thread(null, new TestClass(),"TESTCLASS",1<<18).start();
	}
	public void run()
	{
		//Scanner scan=new Scanner(System.in);
		InputReader hb=new InputReader(System.in);
		PrintWriter w=new PrintWriter(System.out);

		int n=hb.nextInt();
		int k=hb.nextInt();

		ArrayList<Integer> list=new ArrayList<>();
		for(int i=0;i<n;i++)
			list.add(hb.nextInt());

		HashSet<Integer> books=new HashSet<Integer>();
		int price=0;
		for(int i=0;i<n;i++)
		{
			if(books.contains(list.get(i)))
				continue;
			if(books.size()<k)
			{
				books.add(list.get(i));
			}
			else
			{
				int flag=0;
				int flag1=0;
				for(int b:books)
				{
					for(int j=i+1;j<list.size();j++)
					{
						//w.println("Inner: "+b+" "+list.get(j));
						if(list.get(j)==b)
						{
							flag=1;
							break;
						}
					}
					if(flag==0)
					{
						books.remove(b);
						books.add(list.get(i));
						flag1=1;
						break;
					}

				}
				if(flag1==0)
				{
					HashSet<Integer> temp=new HashSet<>();
					for(int x:books)
						temp.add(x);

					for(int j=i;j<n;j++)
					{
						if(temp.size()<=1)
							break;

						if(temp.contains(list.get(j)))
							temp.remove(list.get(j));
					}
					for(int x:temp)
						books.remove(x);
					books.add(list.get(i));
				}

			}
			price++;
		}
		w.print(price);
		w.close();
	}

	private void shuffle(int[] arr)
	{
		Random ran = new Random();
		for (int i = 0; i < arr.length; i++) {
			int i1 = ran.nextInt(arr.length);
			int i2 = ran.nextInt(arr.length);

			int temp = arr[i1];
			arr[i1] = arr[i2];
			arr[i2] = temp;
		}
	}

	static class DSU
	{
		int parent[];
		int sizeParent[];
		DSU(int n)
		{
			parent=new int[n];
			sizeParent=new int[n];
			Arrays.fill(sizeParent,1);
			for(int i=0;i<n;i++)
				parent[i]=i;
		}

		int find(int x)
		{
			if(x!=parent[x])
				parent[x]=find(parent[x]);
			return parent[x];
		}

		void union(int x,int y)
		{
			x=find(x);
			y=find(y);
			if(sizeParent[x]>=sizeParent[y])
			{
				if(x!=y)
					sizeParent[x]+=sizeParent[y];
				parent[y]=x;
			}
			else
			{
				if(x!=y)
					sizeParent[y]+=sizeParent[x];
				parent[x]=y;
			}
		}
	}

	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars==-1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}

				if(numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine()
		{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
		public int nextInt()
		{
			int c = read();

			while(isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;
			do
			{
				if(c<'0'||c>'9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			long res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));
				return res * sgn;
		}

		public double nextDouble()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.')
			{
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.')
			{
				c = read();
				double m = 1;
				while (!isSpaceChar(c))
				{
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public String readString()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = read();
			}
			while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next()
		{
			return readString();
		}

		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}
	}

	static class Pair implements Comparable<Pair>
	{
		int a;
		int b;
		String str;
		public Pair(int a,int b)
		{
			this.a=a;
			this.b=b;
			str=min(a,b)+" "+max(a,b);
		}

		public int compareTo(Pair pair)
		{
			if(Integer.compare(a,pair.a)==0)
				return Integer.compare(b,pair.b);

			return Integer.compare(a,pair.a);
		}
	}

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author niquefa_diego
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int a[] = new int[n];
            for (int i = 0; i < n; ++i)
                a[i] = in.nextInt();

            int lastFound[] = new int[n + 1];
            int next[] = new int[n];
            Arrays.fill(lastFound, n);
            for (int i = n - 1; i >= 0; --i) {
                next[i] = lastFound[a[i]];
                lastFound[a[i]] = i;
            }

            int ans = 0;
            TreeSet<TaskB.S> heap = new TreeSet<TaskB.S>();
            int[] heapNext = new int[n + 1];
            for (int i = 0; i < n; ++i) {
                if (heapNext[a[i]] != 0)
                    heap.remove(new TaskB.S(a[i], heapNext[a[i]]));
                else {
                    ans++;
                    if (heap.size() == k)
                        heapNext[heap.pollFirst().x] = 0;
                }
                heap.add(new TaskB.S(a[i], next[i]));
                heapNext[a[i]] = next[i];
            }

            out.println(ans);
        }

        static class S implements Comparable<TaskB.S> {
            int x;
            int next;

            public int compareTo(TaskB.S o) {
                return o.next - next;
            }

            S(int x, int next) {
                this.x = x;
                this.next = next;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer = null;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.util.*;
import java.io.*;

public class Library {
    public static void main(String [] args) {
        Reader in = new Reader ();
        Writer out = new Writer ();
        int n = in.nextInt();
        int k = in.nextInt();

        int [] a = new int [n + 5];
        for(int i = 1; i <= n; i++) {
            a[i] = in.nextInt();
        }

        int ans = 0;
        TreeSet <Integer> t = new TreeSet <> ();
        TreeSet <Pair> s = new TreeSet <> (new Pair());

        int [] nxt = new int [n + 5];
        int [] last = new int [n + 5];
        Arrays.fill(last, n+1);
        for(int i = n; i >= 1; i--) {
            nxt[i] = last[a[i]];
            last[a[i]] = i;
        }
        Arrays.fill(last, 0);

        for(int i = 1; i <= n; i++) {
            last[a[i]] = i;
            if(t.contains(a[i])) {
                s.remove(new Pair(i, a[i]));
                s.add(new Pair(nxt[i], a[i]));
            }
            else {
                ++ans;
                if(t.size() == k) {
                    int good = s.last().second;
                    t.remove(good);
                    s.remove(new Pair(nxt[last[good]], good));
                }
                t.add(a[i]);
                s.add(new Pair(nxt[i], a[i]));
            }
        }
        System.out.println(ans);
    }
    static class Reader {
        private StringTokenizer a;
        private BufferedReader b;
        Reader () {
            a = null;
            b = new BufferedReader (new InputStreamReader (System.in));
        }
        public String next () {
            while(a == null || !a.hasMoreTokens()) {
                try {
                    a = new StringTokenizer (b.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return a.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(this.next());
        }
        public long nextLong () {
            return Long.parseLong(this.next());
        }
        public double nextDouble () {
            return Double.parseDouble(this.next());
        }
        public String nextLine() {
            try {
                return b.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return "";
        }
    }
    static class Writer {
        private PrintWriter a;
        private StringBuffer b;
        Writer () {
            a = new PrintWriter (System.out);
            b = new StringBuffer ("");
        }
        public void write (Object s) {
            b.append(s);
        }
        public void writeln(Object s) {
            b.append(s).append('\n');
        }
        public void flush () {
            a.print(b);
            a.flush();
            a.close();
        }
    }
    static class Pair implements Comparator <Pair> {
        int first;
        int second;
        Pair  (int a, int b) {
            this.first = a;
            this.second = b;
        }
        Pair (Pair a) {
            this.first = a.first;
            this.second = a.second;
        }
        Pair () {}
        public String toString () {
            return "[" + first + ", " + second + "]";
        }
        public int compare (Pair a, Pair b) {
            if(a.first == b.first) {
                return a.second - b.second;
            } else {
                return a.first - b.first;
            }
        }
    }
}

import java.util.*;
import java.io.*;

public class Library {
    public static void main(String [] args) {
        Reader in = new Reader ();
        Writer out = new Writer ();
        int n = in.nextInt();
        int k = in.nextInt();

        int [] a = new int [n + 5];
        for(int i = 1; i <= n; i++) {
            a[i] = in.nextInt();
        }

        int ans = 0;
        TreeSet <Integer> t = new TreeSet <> ();
        int [] cnt = new int [n + 5];
        for(int i = 1; i <= n; i++) {
            cnt[a[i]] += 1;
        }
        for(int i = 1; i <= n; i++) {
            cnt[a[i]] -= 1;
            if(!t.contains(a[i])) {
                ++ans;
                t.add(a[i]);
                if(t.size() > k) {
                    int good = -1;
                    for(Integer j : t) {
                        if(j == a[i]) continue;
                        if(cnt[j] == 0) {
                            good = j;
                        }
                    }
                    if(good == -1) {
                        int best = -1;
                        for(Integer j : t) {
                            if(j == a[i]) continue;
                            int occ = -1;
                            for(int x = i+1; x <= n; x++) {
                                if(a[x] == j) {
                                    occ = x;
                                    break;
                                }
                            }
                            best = Math.max(best, occ);
                        }
                        good = a[best];
                    }
                    t.remove(good);
                }
            }
        }
        System.out.println(ans);
    }
    static class Reader {
        private StringTokenizer a;
        private BufferedReader b;
        Reader () {
            a = null;
            b = new BufferedReader (new InputStreamReader (System.in));
        }
        public String next () {
            while(a == null || !a.hasMoreTokens()) {
                try {
                    a = new StringTokenizer (b.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return a.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(this.next());
        }
        public long nextLong () {
            return Long.parseLong(this.next());
        }
        public double nextDouble () {
            return Double.parseDouble(this.next());
        }
        public String nextLine() {
            try {
                return b.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return "";
        }
    }
    static class Writer {
        private PrintWriter a;
        private StringBuffer b;
        Writer () {
            a = new PrintWriter (System.out);
            b = new StringBuffer ("");
        }
        public void write (Object s) {
            b.append(s);
        }
        public void writeln(Object s) {
            b.append(s).append('\n');
        }
        public void flush () {
            a.print(b);
            a.flush();
            a.close();
        }
    }
    static class Pair implements Comparator <Pair> {
        int first;
        int second;
        Pair  (int a, int b) {
            this.first = a;
            this.second = b;
        }
        Pair (Pair a) {
            this.first = a.first;
            this.second = a.second;
        }
        Pair () {}
        public String toString () {
            return "[" + first + ", " + second + "]";
        }
        public int compare (Pair a, Pair b) {
            if(a.first == b.first) {
                return a.second - b.second;
            } else {
                return a.first - b.first;
            }
        }
    }
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class BookLibrary{

	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		int days = scanner.nextInt();
		int collections = scanner.nextInt();

		Integer[] borrowBooks = new Integer[days];
		for(int i=0; i<days; i++){
			borrowBooks[i] = scanner.nextInt();
		}

		int availableBook = 0;
		int lastBook = 0;

		Integer[] collection = new Integer[collections];
		for(int i=0; i<collection.length; i++){
			collection[i] = 0;
		}

		int buyNewBook = 0;
		int indexAdded = 0;
		int updated = 0;
		for(int i=0; i<borrowBooks.length; i++){
			Boolean isExist = false;
			Boolean isAvailable = true;

			if(Arrays.asList(collection).indexOf(borrowBooks[i]) != -1){
				isExist = true;
			}

			if(Arrays.asList(collection).indexOf(0) == -1){
				isAvailable = false;
			}

			if(isExist){
				updated++;
			}else{
				if(isAvailable){
					collection[indexAdded] = borrowBooks[i];
					indexAdded += 1;

					buyNewBook++;
				}else{
// 80 4
// 9 9 2 6 3 10 2 5 4 9 6 7 5 5 3 8 5 3 2 10 7 8 5 3 4 9 4 3 9 5 2 10 8 4 7 3 8 3 5 2 3 7 8 4 2 4 4 7 2 2 5 7 5 8 10 10 5 1 1 3 5 2 10 8 7 9 7 4 8 3 2 8 7 9 10 9 7 1 5 5

// 9 2 6 3  | 10 2 5
// 9 2 6 10  | 2 5
// 9 2 6 10 | 5 4 9
// 9 2

					Integer[] newCollection = new Integer[(borrowBooks.length - collection.length -1 -updated)];
					for(int k=0; k<newCollection.length; k++){
						newCollection[k] = borrowBooks[k+collection.length+1+updated];
					}

					int[] findMatchies = new int[collection.length];

					for(int j=0; j<collection.length; j++){
						findMatchies[j] = Arrays.asList(newCollection).indexOf(collection[j]);
					}

					int tempMaxLong = 0;
					int indexLong = 0;
					for(int j=0; j<collection.length; j++){
						if(findMatchies[j] == -1){
							indexLong = j;
							break;
						}

						if(findMatchies[j] > tempMaxLong){
							tempMaxLong = findMatchies[j];
							indexLong = j;
						}
					}

					collection[indexLong] = borrowBooks[i];
					buyNewBook++;

					updated++;
				}
			}
		}
		System.out.println(buyNewBook);
	}

}

import java.util.*;

import java.io.*;

public class Main
{

	public static void main(String[] args) throws IOException
	{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer s = new StringTokenizer(br.readLine());
		int n=Integer.parseInt(s.nextToken());
		int k=Integer.parseInt(s.nextToken());

		s = new StringTokenizer(br.readLine());
		int ar[]=new int[n];
		int freq[]=new int[n+1];
		int last[]=new int[n+1];
		int next[]=new int[n+1];
		for(int i=0;i<ar.length;i++) {
			ar[i]=Integer.parseInt(s.nextToken());
			freq[ar[i]]++;

		}
		Arrays.fill(last, 82);
		int count=0;
		for(int i=1;i<=n;i++) {
			if(freq[i]>0)
				count++;
		}
		if(count<=k) {
			pw.println(count);
			pw.close();
		}
		for(int i=n-1;i>=0;i--) {
			next[i]=last[ar[i]];
			last[ar[i]]=i;
		}
//		for(int i=0;i<n;i++) {
//			pw.println(next[i]);
//		}
		Set<Integer>hm=new HashSet<>();
		int ans=0;

		PriorityQueue<Pair>pq=new PriorityQueue<>((a,b)-> b.j-a.j);
		for(int i=0;i<ar.length;i++) {
			if(pq.size()<k) {
				if(!hm.contains(ar[i])) {
					hm.add(ar[i]);
					ans++;
					pq.add(new Pair(ar[i],next[i]));
				}	else {
					pq.remove(new Pair(ar[i],i));
					pq.add(new Pair(ar[i],next[i]));
				}

			}else {
				if(!hm.contains(ar[i])) {
					ans++;
					int val=pq.poll().i;
					hm.remove(val);
					pq.add(new Pair(ar[i],next[i]));
					hm.add(ar[i]);
				}else {
					pq.remove(new Pair(ar[i],i));
					pq.add(new Pair(ar[i],next[i]));
				}
			}
		}
		pw.println(ans);

		pw.close();

	}

}
class Pair{
	int i;
	int j;
	Pair(int i,int j){
		this.i=i;
		this.j=j;
	}
	 @Override
	  public boolean equals(Object o){
	    if(o instanceof Pair){
	      Pair c = (Pair)o;
	      return i == c.i && j == c.j;
	    }
	    return false;
	  }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class A {

	static StringTokenizer st;
	static BufferedReader br;
	static PrintWriter pw;
	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int n = nextInt();
		int k = nextInt();
		int[]a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		int ans = 0;
		Set<Integer> inLibrary = new HashSet<>();
		int[]first = new int[n+1];
		for (int i = 0; i < n; i++) {
			if (!inLibrary.contains(a[i])) {
				ans++;
				if (inLibrary.size() < k)
					inLibrary.add(a[i]);
				else {
					Arrays.fill(first, n);
					for (int j = n-1; j > i; j--) {
						first[a[j]] = j;
					}
					int maxDay = 0, whatBook = 0;
					for (int j : inLibrary) {
						if (first[j] > maxDay) {
							maxDay = first[j];
							whatBook = j;
						}
					}
					inLibrary.remove(whatBook);
					inLibrary.add(a[i]);
				}
			}
		}
		System.out.println(ans);
		pw.close();
	}
	private static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	private static long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	private static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
	private static String next() throws IOException {
		while (st==null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}
}

import java.util.*;

import java.io.*;

public class Main
{

	public static void main(String[] args) throws IOException
	{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer s = new StringTokenizer(br.readLine());
		int n=Integer.parseInt(s.nextToken());
		int k=Integer.parseInt(s.nextToken());

		s = new StringTokenizer(br.readLine());
		int ar[]=new int[n];
		int last[]=new int[n+1];
		int next[]=new int[n+1];
		for(int i=0;i<ar.length;i++) {
			ar[i]=Integer.parseInt(s.nextToken());
		}
		Arrays.fill(last, 400005);
		for(int i=n-1;i>=0;i--) {
			next[i]=last[ar[i]];
			last[ar[i]]=i;
		}

		Set<Integer>hm=new HashSet<>();
		int ans=0;

		TreeSet<Pair>ts=new TreeSet<>((a,b)-> b.j-a.j);

		for(int i=0;i<ar.length;i++) {
				if(hm.contains(ar[i])) {
					ts.remove(new Pair(ar[i],i));
					ts.add(new Pair(ar[i],next[i]));

				}else {
					if(ts.size()>=k){
						Pair p=ts.first();
						int val=p.i;
						ts.remove(p);
						hm.remove(val);
				}
					hm.add(ar[i]);
					ans++;
					ts.add(new Pair(ar[i],next[i]));
			}
		}
		pw.println(ans);

		pw.close();

	}
}
class Pair{
	int i;
	int j;
	Pair(int i,int j){
		this.i=i;
		this.j=j;
	}

}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class B {

	static StringTokenizer st;
	static BufferedReader br;
	static PrintWriter pw;
	static class Que_Elems implements Comparable<Que_Elems> {
		int id;
		int nextId;
		@Override
		public int compareTo(Que_Elems o) {
			return -(this.nextId-o.nextId);
		}
		public Que_Elems(int id, int nextId) {
			this.id = id;
			this.nextId = nextId;
		}
	}
	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int n = nextInt();
		int k = nextInt();
		int[]a = new int[n];
		int[]next = new int[n];
		int[]last = new int[n+1];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		Arrays.fill(last, n);
		for (int i = n-1; i >= 0; i--) {
			next[i] = last[a[i]];
			last[a[i]] = i;
		}
		int ans = 0;
		PriorityQueue<Que_Elems> q = new PriorityQueue<>();
		Set<Integer> inLibrary = new TreeSet<>();
		for (int i = 0; i < n; i++) {
			if (!inLibrary.contains(a[i])) {
				ans++;
				if (inLibrary.size()==k) {
					int whatBook = q.poll().id;
					inLibrary.remove(a[whatBook]);
				}
				q.add(new Que_Elems(i, next[i]));
				inLibrary.add(a[i]);
			}
		}
		System.out.println(ans);
		pw.close();
	}
	private static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	private static long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	private static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
	private static String next() throws IOException {
		while (st==null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class cdfhelvetic2017a
{
	static void merge(int arr[], int l, int m, int r)
    {
        int n1 = m - l + 1;
        int n2 = r - m;
        int L[] = new int [n1];
        int R[] = new int [n2];
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];
        int i = 0, j = 0;
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }
    static void sort(int arr[], int l, int r)
    {
        if (l < r)
        {
            int m = (l+r)/2;
            sort(arr, l, m);
            sort(arr , m+1, r);
            merge(arr, l, m, r);
        }
    }
    static int gcd(int a, int b)
    {
      if (b == 0)
        return a;
      return gcd(b, a % b);
    }
    static long power(long n,long m)
    {
    	if(m==0)
    		return 1;
    	long ans=1;
    	while(m>0)
    	{
    		ans=ans*n;
    		m--;
    	}
    	return ans;
    }
    static int binarySearch(int arr[], int x)
    {
        int l = 0, r = arr.length - 1;
        while (l <= r) {
            int m = l + (r - l) / 2;
            if (arr[m] == x)
                return m;
            if (arr[m] < x)
                l = m + 1;
            else
                r = m - 1;
        }
        return -1;
    }
	public static void main(String args[])throws Exception
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=1;//Integer.parseInt(br.readLine());
		for(int i=0;i<t;i++)
		{
			String s=br.readLine();
			String str[]=s.split(" ");
			int n=Integer.parseInt(str[0]);
			int cap=Integer.parseInt(str[1]);
			int a[]=new int[cap];//for the books in library
			int b[]=new int[n+1];//for the books taken
			int arr[]=new int[n];//day wala sab hisaab kitaab
			s=br.readLine();
			int tempo=0;
			String ss[]=s.split(" ");
			int dis=0,dis1=0;
			for(int j=0;j<n;j++)
			{
				arr[j]=Integer.parseInt(ss[j]);
				if(tempo<cap&&b[arr[j]]==0)
				{
					a[tempo]=arr[j];
					tempo++;
					b[arr[j]]=1;
					dis++;
					dis1++;
				}
				else if(b[arr[j]]==0)
					dis++;
			}
			if(dis<=cap)
			{
				System.out.println(dis);
				return;
			}
			int cost=dis1;
//			System.out.println(cost);
//			for(int k=0;k<cap;k++)
//			System.out.print(a[k]+" ");
//			System.out.println();
			out1:for(int j=cap;j<n;j++)
			{
				for(int k=0;k<cap;k++)
				{
					if(a[k]==arr[j])
					continue out1;
				}
				int k=0,l=j,pos=0;
				outer:for(k=0;k<cap;k++)
				{
					for(l=j;l<n;l++)
					{
						if(a[k]==arr[l])
						continue outer;
					}
					pos=k;
					break;
				}
				//System.out.println("pos= "+pos);
				a[pos]=arr[j];
				cost++;
			}
			System.out.println(cost);
		}
	}
}

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author da_201612051
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    FastIO in = new FastIO(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskA1 solver = new TaskA1();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskA1 {

    public void solve(int testNumber, FastIO in, PrintWriter out) {
      try {
        int n = in.nextInt();
        int k = in.nextInt();
        int[] query = in.nextIntArray(n);
        int cost = 0;
        Set<Integer> avaialbleBooks = new HashSet<>(k);
        List<Integer> removable = new ArrayList<>(n);
        int[] access = new int[81];
        Arrays.stream(query).forEach(book -> access[book]++);
        for (int i = 0; i < n; i++) {
          int q = query[i];
          if (!avaialbleBooks.contains(q)) {
            cost++;
          }
          --access[q];
          if (!removable.isEmpty()) {
            avaialbleBooks.remove(removable.remove(0));
          }
          if (removable.isEmpty() && avaialbleBooks.size() == k) {
            avaialbleBooks.remove(avaialbleBooks.iterator().next());
          }
          if (avaialbleBooks.size() < k && access[q] > 0) {
            avaialbleBooks.add(q);
          } else if (access[q] == 0) {
            removable.add(q);
          }
        }
        out.println(cost);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

  }

  static class FastIO {

    final private int BUFFER_SIZE = 1 << 16;
    private InputStream din;
    private byte[] buffer;
    private int bufferPointer;
    private int bytesRead;

    public FastIO() {
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
    }

    public FastIO(InputStream inputStream) {
      this();
      din = new DataInputStream(inputStream);
    }

    public FastIO(String file_name) throws IOException {
      din = new DataInputStream(new FileInputStream(file_name));
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
    }

    public int nextInt() throws IOException {
      int ret = 0;
      byte c = read();
      while (c <= ' ') {
        c = read();
      }
      boolean neg = (c == '-');
      if (neg) {
        c = read();
      }
      do {
        ret = ret * 10 + c - '0';
      } while ((c = read()) >= '0' && c <= '9');

      if (neg) {
        return -ret;
      }
      return ret;
    }

    public int[] nextIntArray(int n) throws IOException {
      int[] arr = new int[n];
      for (int i = 0; i < n; i++) {
        arr[i] = nextInt();
      }
      return arr;
    }

    private void fillBuffer() throws IOException {
      bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
      if (bytesRead == -1) {
        buffer[0] = -1;
      }
    }

    private byte read() throws IOException {
      if (bufferPointer == bytesRead) {
        fillBuffer();
      }
      return buffer[bufferPointer++];
    }

  }
}

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author da_201612051
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    FastIO in = new FastIO(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskA1 solver = new TaskA1();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskA1 {

    public void solve(int testNumber, FastIO in, PrintWriter out) {
      try {
        int n = in.nextInt();
        int k = in.nextInt();
        int[] query = in.nextIntArray(n);
        int cost = 0;
        Set<Integer> avaialbleBooks = new HashSet<>(k);
        int[] access = new int[81];
        Arrays.stream(query).forEach(book -> access[book]++);
        for (int i = 0; i < n; i++) {
          if (!avaialbleBooks.contains(query[i])) {
            cost++;
          }
          --access[query[i]];
          if (avaialbleBooks.size() < k && access[query[i]] > 0) {
            avaialbleBooks.add(query[i]);
          } else if (access[query[i]] == 0) {
            avaialbleBooks.remove(query[i]);
          }
        }
        System.out.println(cost);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

  }

  static class FastIO {

    final private int BUFFER_SIZE = 1 << 16;
    private InputStream din;
    private byte[] buffer;
    private int bufferPointer;
    private int bytesRead;

    public FastIO() {
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
    }

    public FastIO(InputStream inputStream) {
      this();
      din = new DataInputStream(inputStream);
    }

    public FastIO(String file_name) throws IOException {
      din = new DataInputStream(new FileInputStream(file_name));
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
    }

    public int nextInt() throws IOException {
      int ret = 0;
      byte c = read();
      while (c <= ' ') {
        c = read();
      }
      boolean neg = (c == '-');
      if (neg) {
        c = read();
      }
      do {
        ret = ret * 10 + c - '0';
      } while ((c = read()) >= '0' && c <= '9');

      if (neg) {
        return -ret;
      }
      return ret;
    }

    public int[] nextIntArray(int n) throws IOException {
      int[] arr = new int[n];
      for (int i = 0; i < n; i++) {
        arr[i] = nextInt();
      }
      return arr;
    }

    private void fillBuffer() throws IOException {
      bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
      if (bytesRead == -1) {
        buffer[0] = -1;
      }
    }

    private byte read() throws IOException {
      if (bufferPointer == bytesRead) {
        fillBuffer();
      }
      return buffer[bufferPointer++];
    }

  }
}

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author da_201612051
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    FastIO in = new FastIO(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskA1 solver = new TaskA1();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskA1 {

    public void solve(int testNumber, FastIO in, PrintWriter out) {
      try {
        int n = in.nextInt();
        int k = in.nextInt();
        int[] query = in.nextIntArray(n);
        int cost = 0;
        Set<Integer> avaialbleBooks = new HashSet<>(k);
        int[] access = new int[81];
        Arrays.stream(query).forEach(book -> access[book]++);
        for (int i = 0; i < n; i++) {
          if (!avaialbleBooks.contains(query[i])) {
            cost++;
          }
          --access[query[i]];
          if (avaialbleBooks.size() < k && access[query[i]] > 0) {
            avaialbleBooks.add(query[i]);
          } else if (access[query[i]] == 0) {
            avaialbleBooks.remove(query[i]);
          }
        }
        out.println(cost);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

  }

  static class FastIO {

    final private int BUFFER_SIZE = 1 << 16;
    private InputStream din;
    private byte[] buffer;
    private int bufferPointer;
    private int bytesRead;

    public FastIO() {
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
    }

    public FastIO(InputStream inputStream) {
      this();
      din = new DataInputStream(inputStream);
    }

    public FastIO(String file_name) throws IOException {
      din = new DataInputStream(new FileInputStream(file_name));
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
    }

    public int nextInt() throws IOException {
      int ret = 0;
      byte c = read();
      while (c <= ' ') {
        c = read();
      }
      boolean neg = (c == '-');
      if (neg) {
        c = read();
      }
      do {
        ret = ret * 10 + c - '0';
      } while ((c = read()) >= '0' && c <= '9');

      if (neg) {
        return -ret;
      }
      return ret;
    }

    public int[] nextIntArray(int n) throws IOException {
      int[] arr = new int[n];
      for (int i = 0; i < n; i++) {
        arr[i] = nextInt();
      }
      return arr;
    }

    private void fillBuffer() throws IOException {
      bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
      if (bytesRead == -1) {
        buffer[0] = -1;
      }
    }

    private byte read() throws IOException {
      if (bufferPointer == bytesRead) {
        fillBuffer();
      }
      return buffer[bufferPointer++];
    }

  }
}

//package codeforces.HCCOM;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Iterator;

/**
 * Created by Abhilash on 28-05-2017.
 */
public class HeidiAndLibrary {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
        String[] vals = br.readLine().split( " " );
        int n = Integer.parseInt( vals[0] );
        int k = Integer.parseInt( vals[1] );
        vals = br.readLine().split( " " );
        HashSet<Integer> books = new HashSet<>();
        if ( n <= k ) {
            for ( int i = 0; i < n; i++ )
                books.add( Integer.parseInt( vals[i] ) );
            System.out.println( books.size() );
        }
        else {
            int[] nums = new int[n];
            for ( int i = 0; i < n; i++ )
                nums[i] = Integer.parseInt( vals[i] );
            int cnt = 0;
            int i = 0;
            while ( books.size() < k )
                books.add( Integer.parseInt( vals[i++] ) );
            cnt = books.size();
            while ( i < n ) {
                int index = i;
                int tempk = k;
                HashSet<Integer> required = new HashSet<>();
                while ( index < n && tempk > 0 ) {
                    if ( books.contains( nums[index] ) && ! required.contains( nums[index] ) ) {
                        tempk--;
                        required.add( nums[index] );
                    }
                    index++;
                }
                int temp = 0;
                Iterator<Integer> it = books.iterator();
                while ( it.hasNext() ) {
                    temp = it.next();
                    if ( tempk == k )
                        break;
                    if ( ! required.contains( temp ) )
                        break;
                }
                books.remove( temp );
                books.add( nums[i] );
                cnt++;
                while ( i < n && books.contains( nums[i] ) )
                    i++;
            }
            System.out.println( cnt );
        }
    }
}

//package codeforces.HCCOM;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Iterator;

/**
 * Created by Abhilash on 28-05-2017.
 */
public class HeidiAndLibrary {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
        String[] vals = br.readLine().split( " " );
        int n = Integer.parseInt( vals[0] );
        int k = Integer.parseInt( vals[1] );
        vals = br.readLine().split( " " );
        HashSet<Integer> books = new HashSet<>();
        if ( n <= k ) {
            for ( int i = 0; i < n; i++ )
                books.add( Integer.parseInt( vals[i] ) );
            System.out.println( books.size() );
        }
        else {
            int[] nums = new int[n];
            for ( int i = 0; i < n; i++ )
                nums[i] = Integer.parseInt( vals[i] );
            int cnt = 0;
            int i = 0;
            while ( books.size() < k )
                books.add( Integer.parseInt( vals[i++] ) );
            cnt = books.size();
            if ( i < n ) {
                do {
                    int index = i;
                    int tempk = k;
                    HashSet<Integer> required = new HashSet<>();
                    while ( index < n && k > 0 ) {
                        if ( books.contains( nums[index] ) ) {
                            k--;
                            required.add( nums[index] );
                        }
                        index++;
                    }
                    int temp = 0;
                    Iterator<Integer> it = books.iterator();
                    while ( it.hasNext() ) {
                        temp = it.next();
                        if ( ! required.contains( temp ) )
                            break;
                    }
                    books.remove( temp );
                    books.add( nums[i] );
                    cnt++;
                    while ( i < n && books.contains( nums[i] ) )
                        i++;
                } while ( i < n );
            }
            System.out.println( cnt );
        }
    }
}

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author da_201612051
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    FastIO in = new FastIO(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskA1 solver = new TaskA1();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskA1 {

    public void solve(int testNumber, FastIO in, PrintWriter out) {
      try {
        int n = in.nextInt();
        int k = in.nextInt();
        int[] query = in.nextIntArray(n);
        int cost = 0;
        Set<Integer> avaialbleBooks = new HashSet<>(k);
        int[] access = new int[81];
        Arrays.stream(query).forEach(book -> access[book]++);
        for (int i = 0; i < n; i++) {
          if (!avaialbleBooks.contains(query[i])) {
            cost++;
          }
          if (avaialbleBooks.size() < k && --access[query[i]] > 0) {
            avaialbleBooks.add(query[i]);
          } else if (access[query[i]] == 0) {
            avaialbleBooks.remove(query[i]);
          }
        }
        System.out.println(cost);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

  }

  static class FastIO {

    final private int BUFFER_SIZE = 1 << 16;
    private InputStream din;
    private byte[] buffer;
    private int bufferPointer;
    private int bytesRead;

    public FastIO() {
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
    }

    public FastIO(InputStream inputStream) {
      this();
      din = new DataInputStream(inputStream);
    }

    public FastIO(String file_name) throws IOException {
      din = new DataInputStream(new FileInputStream(file_name));
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
    }

    public int nextInt() throws IOException {
      int ret = 0;
      byte c = read();
      while (c <= ' ') {
        c = read();
      }
      boolean neg = (c == '-');
      if (neg) {
        c = read();
      }
      do {
        ret = ret * 10 + c - '0';
      } while ((c = read()) >= '0' && c <= '9');

      if (neg) {
        return -ret;
      }
      return ret;
    }

    public int[] nextIntArray(int n) throws IOException {
      int[] arr = new int[n];
      for (int i = 0; i < n; i++) {
        arr[i] = nextInt();
      }
      return arr;
    }

    private void fillBuffer() throws IOException {
      bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
      if (bytesRead == -1) {
        buffer[0] = -1;
      }
    }

    private byte read() throws IOException {
      if (bufferPointer == bytesRead) {
        fillBuffer();
      }
      return buffer[bufferPointer++];
    }

  }
}

//package codeforces.HCCOM;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Iterator;

/**
 * Created by Abhilash on 28-05-2017.
 */
public class HeidiAndLibrary {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
        String[] vals = br.readLine().split( " " );
        int n = Integer.parseInt( vals[0] );
        int k = Integer.parseInt( vals[1] );
        vals = br.readLine().split( " " );
        HashSet<Integer> books = new HashSet<>();
        if ( n <= k ) {
            for ( int i = 0; i < n; i++ )
                books.add( Integer.parseInt( vals[i] ) );
            System.out.println( books.size() );
        }
        else {
            int[] nums = new int[n];
            for ( int i = 0; i < n; i++ )
                nums[i] = Integer.parseInt( vals[i] );
            int cnt = 0;
            int i = 0;
            while ( books.size() < k )
                books.add( Integer.parseInt( vals[i++] ) );
            cnt = books.size();
            if ( i < n ) {
                do {
                    int index = i;
                    int tempk = k;
                    HashSet<Integer> required = new HashSet<>();
                    while ( index < n && tempk > 0 ) {
                        if ( books.contains( nums[index] ) ) {
                            tempk--;
                            required.add( nums[index] );
                        }
                        index++;
                    }
                    int temp = 0;
                    Iterator<Integer> it = books.iterator();
                    while ( it.hasNext() ) {
                        temp = it.next();
                        if ( ! required.contains( temp ) )
                            break;
                    }
                    books.remove( temp );
                    books.add( nums[i] );
                    cnt++;
                    while ( i < n && books.contains( nums[i] ) )
                        i++;
                } while ( i < n );
            }
            System.out.println( cnt );
        }
    }
}

//package codeforces.HCCOM;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Iterator;

/**
 * Created by Abhilash on 28-05-2017.
 */
public class HeidiAndLibrary {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
        String[] vals = br.readLine().split( " " );
        int n = Integer.parseInt( vals[0] );
        int k = Integer.parseInt( vals[1] );
        vals = br.readLine().split( " " );
        HashSet<Integer> books = new HashSet<>();
        if ( n <= k ) {
            for ( int i = 0; i < n; i++ )
                books.add( Integer.parseInt( vals[i] ) );
            System.out.println( books.size() );
        }
        else {
            int[] nums = new int[n];
            for ( int i = 0; i < n; i++ )
                nums[i] = Integer.parseInt( vals[i] );
            int cnt = 0;
            int i = 0;
            while ( books.size() < k )
                books.add( Integer.parseInt( vals[i++] ) );
            cnt = books.size();
            if ( i < n ) {
                do {
                    int index = i;
                    int tempk = k;
                    HashSet<Integer> required = new HashSet<>();
                    while ( index < n && tempk > 0 ) {
                        if ( books.contains( nums[index] ) ) {
                            tempk--;
                            required.add( nums[index] );
                        }
                        index++;
                    }
                    int temp = 0;
                    Iterator<Integer> it = books.iterator();
                    while ( it.hasNext() ) {
                        temp = it.next();
                        if ( tempk == k )
                            break;
                        if ( ! required.contains( temp ) )
                            break;
                    }
                    books.remove( temp );
                    books.add( nums[i] );
                    cnt++;
                    while ( i < n && books.contains( nums[i] ) )
                        i++;
                } while ( i < n );
            }
            System.out.println( cnt );
        }
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            TreeSet<Integer> books = new TreeSet<>();
            int ans = 0;
            for (int i = 0; i < n; i++) {
                if (!books.contains(a[i])) {
                    ans++;
                    if (books.size() < k) {
                        books.add(a[i]);
                    } else {
                        int unused = books.iterator().next();
                        TreeSet<Integer> nextBooks = new TreeSet<>();
                        for (int j = n - 1; j > i; j--) {
                            nextBooks.add(a[j]);
                        }
                        for (int book : books) {
                            if (!nextBooks.contains(book)) {
                                unused = book;
                                break;
                            }
                        }
                        books.remove(unused);
                        books.add(a[i]);
                    }
                }
            }
            out.println(ans);
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.util.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;

public class Main implements Runnable{

	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars==-1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}

				if(numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine()
		{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
		}
		public int nextInt()
		{
			int c = read();

			while(isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;
			do
			{
				if(c<'0'||c>'9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			long res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));
				return res * sgn;
		}

		public double nextDouble()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.')
			{
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.')
			{
				c = read();
				double m = 1;
				while (!isSpaceChar(c))
				{
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public String readString()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = read();
			}
			while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next()
		{
			return readString();
		}

		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}
	}
	static LinkedList <Integer> adj[];

    static void Check2(int n){
        adj=new LinkedList[n+1];
        for(int i=0;i<=n;i++){
            adj[i]=new LinkedList();
        }

    }
    static void add(int i,int j){
       // if(!adj[i].contains(j))
        adj[i].add(j);
   // if(!adj[j].contains(i))
        adj[j].add(i);

     //   adj[j].add(i);

    }
	  public static void main(String[] args) throws Exception {
    new Thread(null, new Main(), "Check2", 1<<26).start();// to increse stack size in java
  }
    static int flag2=1;
    static int ne=0;
  public void run(){
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        //Scanner in=new Scanner(System.in);
    InputReader in=new InputReader(System.in);
		PrintWriter w=new PrintWriter(System.out);

   int n=in.nextInt();

      int k=in.nextInt();

      int a[]=new int[n];
      for(int i=0;i<n;i++)
      {
          a[i]=in.nextInt();
      }

   if(k>=n){
       HashMap <Integer,Integer> map=new HashMap();
          for(int i=0;i<n;i++){

              map.put(a[i],1);
             // cost++;
          }

       w.println(map.size());
   }
      else{

          int cost=0;

          HashMap <Integer,Integer> map=new HashMap();
          for(int i=0;i<k;i++){

              map.put(a[i],1);
             // cost++;
          }

          cost=map.size();
          for(int i=k;i<n;i++)
          {

              int f[]=new int[n+1];
                      HashMap <Integer,Integer> map2=new HashMap();
  if(map.containsKey(a[i])){
      continue;
  }
              for(int j=i+1;j<n;j++){
                  if(map.containsKey(a[j])){
                      f[a[j]]++;
                      if(!map2.containsKey(a[j]))
                      map2.put(a[j],j);
                  }

              }
              int flag=0;
              int min=Integer.MAX_VALUE;
              int id=-1;
                 for (Map.Entry<Integer,Integer> entry : map.entrySet()) {
    int key = entry.getKey();
    int value = entry.getValue();

                     if(f[key]<min){
                         flag=1;
                         min=f[key];
                         id=key;
                     }
                     else if(f[key]==min)
                     {
                         id=min(map2.get(id),map2.get(key));
                     }

                 }

   //           System.out.println(id+" "+min);
              if(flag==1){
              map.remove(id);
                  cost++;
              }
              else
                  {
                  int ide=-1;
                  for (Map.Entry<Integer,Integer> entry : map.entrySet()) {
    int key = entry.getKey();
    int value = entry.getValue();
   ide=key;
                      break;
}

                  map.remove(ide);

                  cost++;
              }
              map.put(a[i],1);
          }

          w.println(cost);

      }

        w.close();

    }
    static class node{

        int y;
        int val;

        node(int a,int b){

            y=a;
            val=b;

        }

    }

}

import java.util.Scanner;
import java.util.Arrays;
import java.io.PrintWriter;

public class Main
{
        private static final Scanner in=new Scanner(System.in);
        private static final PrintWriter out=new PrintWriter(System.out);

	public static void main (String[] args) throws java.lang.Exception
	{
		int n=in.nextInt(), k=in.nextInt(), a[]=new int[n], b[]=new int[n], books=0;

                Arrays.fill(b,0);
                for(int i=0;i<n;i++) {
                 a[i]=in.nextInt()-1;
                }
                in.close();

                int counter=0;
                for(int i=0;i<n;i++) {
                 if(b[a[i]]==0) {
                   ++books; ++counter;
                   if(counter>k) {
                    int least=check(a,b,i);
                    //System.out.printf("%d %d %d\n",i,least, a[least]+1);
                    b[a[least]]=0;
                    counter-=1;
                   }
                   b[a[i]]=1;
                 }
                }

                out.print("cost="+books);
                out.close();
        }

        private static int check(int a[], int b[], int n) {
         int max=-1000, pos=-1, mpos=-1; boolean x;
         for(int i=0;i<a.length;i++) {
          if(b[a[i]]==1) {
           x=false; int j=n+1;
           for(;j<a.length;j++) {
             if(a[i]==a[j]) {
              x=!x;
              if(max<(j-n)) max=(j-n);
              //System.out.println("max of "+(a[i]+1)+"="+max+"and pos="+pos);
              pos=j; if(mpos<pos) mpos=pos;
              break;
             }
           }
           if(!x) {
              //System.out.println("executed");
            return i;
           }
         }
        }
        return mpos;
       }

}

import java.util.Scanner;
import java.util.Arrays;
import java.io.PrintWriter;

public class Main
{
        private static final Scanner in=new Scanner(System.in);
        private static final PrintWriter out=new PrintWriter(System.out);

	public static void main (String[] args) throws java.lang.Exception
	{
		int n=in.nextInt(), k=in.nextInt(), a[]=new int[n], b[]=new int[n], c[]=new int[n], books=0;

                Arrays.fill(b,0); Arrays.fill(c,0);
                for(int i=0;i<n;i++) {
                 a[i]=in.nextInt()-1;
                 c[a[i]]++;
                }
                in.close();

                int counter=0;
                for(int i=0;i<n;i++) {
                 if(b[a[i]]==0) {
                   ++books; ++counter;
                   if(counter>k) {
                    int least=check(b,c);
                    b[least]=0;
                    counter-=1;
                   }
                   b[a[i]]=1;
                   --c[a[i]];
                 }
                }

                out.print(books);
                out.close();
        }

        private static int check(int b[], int c[]) {
         int least=Integer.MAX_VALUE, pos=-1;
         for(int i=0;i<b.length;i++) {
          if(b[i]==0) continue;
          if(least>c[i]) {
           least=c[i];
           pos=i;
          }
         }
         return pos;
        }
}

// CodeForces Round #815 A TODO
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class  HeidiLibrary {

	int n,k;
	int []a;
	int []lib;
	int minCost;

	private void readData(BufferedReader bin) throws IOException {
		String s = bin.readLine();
		String[] ss = s.split(" ");
		// read x,y,l,r
		n = Integer.parseInt(ss[0]);
		k = Integer.parseInt(ss[1]);
		// read a
		s = bin.readLine();
		ss = s.split(" ");
		a = new int[n];
		for (int i=0; i<n; i++) {
			a[i] = Integer.parseInt(ss[i]);
		}
	}

	void printRes() {
		System.out.println(minCost);
	}

	/**
	 * check if we have book in library, so we don't have to buy it
	 * @param lib - library array like [1, 3, 5]
	 * @param book - book like 3
	 * @return - true if we have book, false if not
	 */
	boolean haveBook(int book) {
		boolean have=false;
		for (int i=0; i<lib.length; i++) {
			if (book==lib[i]) {
				have = true;
			}
		}
		return have;
	}

	/**
	 * when book will be needed next time
	 * @return
	 */
	int nextUse(int book, int aIdx) {
		int nu = 1000000;
		for (int i=aIdx+1; i<n; i++) {
			if (book == a[i]) {
				nu = i;
				break;
			}
		}
		return nu;
	}

	/** replace least useful book in library by book */
	void addBook(int book, int aIdx) {
		int nu, lastUse = -1000000;
		int idxLastUse = 0;
		// looking book with largest nextUse to throw away
		for (int i=0; i<lib.length; i++) {
			nu = nextUse(lib[i], aIdx);
			if (nu > lastUse) {
				lastUse = nu;
				idxLastUse = i;
			}
		}
		// replacing book
		System.out.println("replaced " + lib[idxLastUse] + " with " + book);
		lib[idxLastUse] = book;
	}

	private void calculate() {
		lib = new int[k];
		for (int i=0; i<n; i++) {
			if (!haveBook(a[i])) {
				minCost++;
				addBook(a[i], i);
			}
		}
	}

	public static void main(String[] args) throws IOException {
		// BufferedReader bin = new BufferedReader(new FileReader("cactus.in"));
		BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
		HeidiLibrary l = new HeidiLibrary();
		l.readData(bin);
		l.calculate();
		l.printRes();
	}
}

// CodeForces Round #815 A TODO
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class  HeidiLibrary {

	int n,k;
	int []a;
	int []lib;
	int minCost;

	private void readData(BufferedReader bin) throws IOException {
		String s = bin.readLine();
		String[] ss = s.split(" ");
		// read x,y,l,r
		n = Integer.parseInt(ss[0]);
		k = Integer.parseInt(ss[1]);
		// read a
		s = bin.readLine();
		ss = s.split(" ");
		a = new int[n];
		for (int i=0; i<n; i++) {
			a[i] = Integer.parseInt(ss[i]);
		}
	}

	void printRes() {
		System.out.println(minCost);
	}

	/**
	 * check if we have book in library, so we don't have to buy it
	 * @param lib - library array like [1, 3, 5]
	 * @param book - book like 3
	 * @return - true if we have book, false if not
	 */
	boolean haveBook(int book) {
		boolean have=false;
		for (int i=0; i<lib.length; i++) {
			if (book==lib[i]) {
				have = true;
			}
		}
		return have;
	}

	/**
	 * when book will be needed next time
	 * @return
	 */
	int nextUse(int book, int aIdx) {
		int nu = 1000000;
		for (int i=aIdx; i<n; i++) {
			if (book == a[i]) {
				nu = i;
			}
		}
		return nu;
	}

	/** replace least useful book in library by book */
	void addBook(int book, int aIdx) {
		int nu, lastUse = -1000000;
		int idxLastUse = 0;
		// looking book with largest nextUse to throw away
		for (int i=0; i<lib.length; i++) {
			nu = nextUse(lib[i], aIdx);
			if (nu > lastUse) {
				lastUse = nu;
				idxLastUse = i;
			}
		}
		// replacing book
		lib[idxLastUse] = book;
	}

	private void calculate() {
		lib = new int[k];
		for (int i=0; i<n; i++) {
			if (!haveBook(a[i])) {
				minCost++;
				addBook(a[i], i);
			}
		}
	}

	public static void main(String[] args) throws IOException {
		// BufferedReader bin = new BufferedReader(new FileReader("cactus.in"));
		BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
		HeidiLibrary l = new HeidiLibrary();
		l.readData(bin);
		l.calculate();
		l.printRes();
	}
}

import java.util.*;
import java.io.*;
  public class Task {

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static Map<Integer,List<Integer>> map=new HashMap<>();

static int cmp(int[] a, int[] b){
    if(map.get(b[0]).size()<=b[1]+1){return 1;}
    if(map.get(a[0]).size()<=a[1]+1){return -1;}
    return map.get(b[0]).get(b[1]+1)-map.get(a[0]).get(a[1]+1);
}
  public static void main(String args[]) throws  IOException {
        assign();
        int[] n1=int_arr();
        int n=n1[0],k=n1[1],res=0;
        int[] b=int_arr();
        int[] f=new int[n+1];
        for(int i=0;i<n;i++){
            map.computeIfAbsent(b[i],k1->new ArrayList<>()).add(i);
        }
        Set<Integer> s=new HashSet<>();
        PriorityQueue<int[]> pq=new PriorityQueue<>((a,b1)->cmp(a,b1));
        for(int i=0;i<n;i++){
            if(s.contains(b[i])){
                f[b[i]]++;
                continue;
            }
            if(s.size()<k){
                pq.add(new int[]{b[i],f[b[i]]});
                f[b[i]]++;res++;
            }
            else{
                int[] z=pq.poll();
                f[z[0]]++;
                pq.add(new int[]{b[i],f[b[i]]});
                f[b[i]]++;res++;
                s.remove(z[0]);
            }
            s.add(b[i]);
        }

        out.write(res+"\n");

             out.flush();
    }

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ahcl
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            for (int i = 0; i < n; i++) {
                out.print(a[i] + " ");
            }
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public boolean contains(Set s, int[] a, int x) {
            Iterator it = s.iterator();
            while (it.hasNext()) {
                int v = (int) it.next();
                if (a[v] == a[x]) return true;
            }
            return false;
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int a[] = new int[n + 100];
            Set s = new TreeSet();
            int next[] = new int[200];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            for (int i = 0; i < 150; i++) {
                next[i] = -1;
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < i; j++) {
                    if (a[j] == a[i] && next[j] == -1) {
                        next[j] = i;
                    }
                }
            }
            for (int i = 0; i < n; i++) {
                if (next[i] == -1) next[i] = 150;
            }
            int ans = 0;
            for (int i = 0; i < n; i++) {
                if (s.size() < k) {
                    if (contains(s, a, i)) continue;
                    else {
                        s.add(i);
                        ans++;
                    }
                } else {
                    if (contains(s, a, i)) continue;
                    else {
                        Iterator it = s.iterator();
                        int max = 0;
                        int loai = -1;
                        while (it.hasNext()) {
                            int x = (int) it.next();
                            if (next[x] > max) {
                                max = next[x];
                                loai = x;
                            }
                        }
                        s.remove(loai);
                        s.add(i);
                        ans++;
                    }
                }
            }
            out.print(ans);
        }

    }
}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * #
 *
 * @author pttrung
 */
public class A_Helvetic_2017_Easy {

	public static long MOD = 1000000007;

	public static void main(String[] args) throws FileNotFoundException {
		// PrintWriter out = new PrintWriter(new FileOutputStream(new File(
		// "output.txt")));
		PrintWriter out = new PrintWriter(System.out);
		Scanner in = new Scanner();
		int n = in.nextInt();
		int k = in.nextInt();
		int[] data = new int[n];
		for (int i = 0; i < n; i++) {
			data[i] = in.nextInt() - 1;
		}
		boolean[] check = new boolean[n];
		int[] last = new int[n];
		Arrays.fill(last, -1);
		int[][] next = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				next[i][j] = last[j];
			}
			last[data[i]] = i;
		}
		int count = 0;
		int result = 0;
		for (int i = 0; i < n; i++) {
			if (!check[data[i]]) {
				if (count < k) {
					count++;
				} else {
					int max = -1;
					for (int j = 0; j < n; j++) {
						if (check[j]) {
							if (max == -1 || (next[i][max] != -1 && next[i][max] < next[i][j]) || next[i][j] == -1) {
								max = j;
							}
						}
					}
					check[max] = false;
				}
				result++;
				check[data[i]] = true;
			}
		}
		out.println(result);

		out.close();
	}

	public static int[] KMP(String val) {
		int i = 0;
		int j = -1;
		int[] result = new int[val.length() + 1];
		result[0] = -1;
		while (i < val.length()) {
			while (j >= 0 && val.charAt(j) != val.charAt(i)) {
				j = result[j];
			}
			j++;
			i++;
			result[i] = j;
		}
		return result;

	}

	public static boolean nextPer(int[] data) {
		int i = data.length - 1;
		while (i > 0 && data[i] < data[i - 1]) {
			i--;
		}
		if (i == 0) {
			return false;
		}
		int j = data.length - 1;
		while (data[j] < data[i - 1]) {
			j--;
		}
		int temp = data[i - 1];
		data[i - 1] = data[j];
		data[j] = temp;
		Arrays.sort(data, i, data.length);
		return true;
	}

	public static int digit(long n) {
		int result = 0;
		while (n > 0) {
			n /= 10;
			result++;
		}
		return result;
	}

	public static double dist(long a, long b, long x, long y) {
		double val = (b - a) * (b - a) + (x - y) * (x - y);
		val = Math.sqrt(val);
		double other = x * x + a * a;
		other = Math.sqrt(other);
		return val + other;

	}

	public static class Point implements Comparable<Point> {

		int x, y;

		public Point(int start, int end) {
			this.x = start;
			this.y = end;
		}

		@Override
		public int hashCode() {
			int hash = 5;
			hash = 47 * hash + this.x;
			hash = 47 * hash + this.y;
			return hash;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			final Point other = (Point) obj;
			if (this.x != other.x) {
				return false;
			}
			if (this.y != other.y) {
				return false;
			}
			return true;
		}

		@Override
		public int compareTo(Point o) {
			return Integer.compare(x, o.x);
		}
	}

	public static class FT {

		long[] data;

		FT(int n) {
			data = new long[n];
		}

		public void update(int index, long value) {
			while (index < data.length) {
				data[index] += value;
				index += (index & (-index));
			}
		}

		public long get(int index) {
			long result = 0;
			while (index > 0) {
				result += data[index];
				index -= (index & (-index));
			}
			return result;

		}
	}

	public static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	public static long pow(long a, long b) {
		if (b == 0) {
			return 1;
		}
		if (b == 1) {
			return a;
		}
		long val = pow(a, b / 2);
		if (b % 2 == 0) {
			return val * val % MOD;
		} else {
			return val * (val * a % MOD) % MOD;

		}
	}

	static class Scanner {

		BufferedReader br;
		StringTokenizer st;

		public Scanner() throws FileNotFoundException {
			// System.setOut(new PrintStream(new
			// BufferedOutputStream(System.out), true));
			br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new
			// FileInputStream(new File("input.txt"))));
		}

		public String next() {

			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					throw new RuntimeException();
				}
			}
			return st.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			st = null;
			try {
				return br.readLine();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}

		public boolean endLine() {
			try {
				String next = br.readLine();
				while (next != null && next.trim().isEmpty()) {
					next = br.readLine();
				}
				if (next == null) {
					return true;
				}
				st = new StringTokenizer(next);
				return st.hasMoreTokens();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}
	}
}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * #
 *
 * @author pttrung
 */
public class A_Helvetic_2017_Easy {

	public static long MOD = 1000000007;

	public static void main(String[] args) throws FileNotFoundException {
		// PrintWriter out = new PrintWriter(new FileOutputStream(new File(
		// "output.txt")));
		PrintWriter out = new PrintWriter(System.out);
		Scanner in = new Scanner();
		int n = in.nextInt();
		int k = in.nextInt();
		int[] data = new int[n];
		for (int i = 0; i < n; i++) {
			data[i] = in.nextInt() - 1;
		}
		boolean[] check = new boolean[n];
		int[] last = new int[n];
		Arrays.fill(last, -1);
		int[][] next = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				next[i][j] = last[j];
			}
			last[data[i]] = i;
		}
		int count = 0;
		int result = 0;
		for (int i = 0; i < n; i++) {
			if (!check[data[i]]) {
				if (count < k) {
					count++;
				} else {
					int max = -1;
					for (int j = 0; j < n; j++) {
						if (check[j]) {
							if (max == -1 || (last[max] != -1 && last[max] < last[j]) || last[j] == -1) {
								max = j;
							}
						}
					}
					check[max] = false;
				}
				result++;
				check[data[i]] = true;
			}
		}
		out.println(result);

		out.close();
	}

	public static int[] KMP(String val) {
		int i = 0;
		int j = -1;
		int[] result = new int[val.length() + 1];
		result[0] = -1;
		while (i < val.length()) {
			while (j >= 0 && val.charAt(j) != val.charAt(i)) {
				j = result[j];
			}
			j++;
			i++;
			result[i] = j;
		}
		return result;

	}

	public static boolean nextPer(int[] data) {
		int i = data.length - 1;
		while (i > 0 && data[i] < data[i - 1]) {
			i--;
		}
		if (i == 0) {
			return false;
		}
		int j = data.length - 1;
		while (data[j] < data[i - 1]) {
			j--;
		}
		int temp = data[i - 1];
		data[i - 1] = data[j];
		data[j] = temp;
		Arrays.sort(data, i, data.length);
		return true;
	}

	public static int digit(long n) {
		int result = 0;
		while (n > 0) {
			n /= 10;
			result++;
		}
		return result;
	}

	public static double dist(long a, long b, long x, long y) {
		double val = (b - a) * (b - a) + (x - y) * (x - y);
		val = Math.sqrt(val);
		double other = x * x + a * a;
		other = Math.sqrt(other);
		return val + other;

	}

	public static class Point implements Comparable<Point> {

		int x, y;

		public Point(int start, int end) {
			this.x = start;
			this.y = end;
		}

		@Override
		public int hashCode() {
			int hash = 5;
			hash = 47 * hash + this.x;
			hash = 47 * hash + this.y;
			return hash;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			final Point other = (Point) obj;
			if (this.x != other.x) {
				return false;
			}
			if (this.y != other.y) {
				return false;
			}
			return true;
		}

		@Override
		public int compareTo(Point o) {
			return Integer.compare(x, o.x);
		}
	}

	public static class FT {

		long[] data;

		FT(int n) {
			data = new long[n];
		}

		public void update(int index, long value) {
			while (index < data.length) {
				data[index] += value;
				index += (index & (-index));
			}
		}

		public long get(int index) {
			long result = 0;
			while (index > 0) {
				result += data[index];
				index -= (index & (-index));
			}
			return result;

		}
	}

	public static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	public static long pow(long a, long b) {
		if (b == 0) {
			return 1;
		}
		if (b == 1) {
			return a;
		}
		long val = pow(a, b / 2);
		if (b % 2 == 0) {
			return val * val % MOD;
		} else {
			return val * (val * a % MOD) % MOD;

		}
	}

	static class Scanner {

		BufferedReader br;
		StringTokenizer st;

		public Scanner() throws FileNotFoundException {
			// System.setOut(new PrintStream(new
			// BufferedOutputStream(System.out), true));
			br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new
			// FileInputStream(new File("input.txt"))));
		}

		public String next() {

			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					throw new RuntimeException();
				}
			}
			return st.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			st = null;
			try {
				return br.readLine();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}

		public boolean endLine() {
			try {
				String next = br.readLine();
				while (next != null && next.trim().isEmpty()) {
					next = br.readLine();
				}
				if (next == null) {
					return true;
				}
				st = new StringTokenizer(next);
				return st.hasMoreTokens();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}
	}
}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * #
 *
 * @author pttrung
 */
public class A_Helvetic_2017_Easy {

	public static long MOD = 1000000007;

	public static void main(String[] args) throws FileNotFoundException {
		// PrintWriter out = new PrintWriter(new FileOutputStream(new File(
		// "output.txt")));
		PrintWriter out = new PrintWriter(System.out);
		Scanner in = new Scanner();
		int n = in.nextInt();
		int k = in.nextInt();
		int[] data = new int[n];
		for (int i = 0; i < n; i++) {
			data[i] = in.nextInt() - 1;
		}
		boolean[] check = new boolean[n];
		int[] last = new int[n];
		Arrays.fill(last, -1);
		int[][] next = new int[n][n];
		for (int i = n - 1; i >= 0; i--) {
			for (int j = 0; j < n; j++) {
				next[i][j] = last[j];
			}
			last[data[i]] = i;
		}
		int count = 0;
		int result = 0;
		for (int i = 0; i < n; i++) {
			if (!check[data[i]]) {
				if (count < k) {
					count++;
				} else {
					int max = -1;
					for (int j = 0; j < n; j++) {
						if (check[j]) {
							// if (i == 2)
							// System.out.println(j + " " + next[i][j]);
							if (max == -1 || (next[i][max] != -1 && next[i][max] < next[i][j]) || next[i][j] == -1) {
								max = j;
							}
						}
					}
					System.out.println(i + " " + max + " " + next[i][max]);
					check[max] = false;
				}
				result++;
				check[data[i]] = true;
			}
		}
		out.println(result);

		out.close();
	}

	public static int[] KMP(String val) {
		int i = 0;
		int j = -1;
		int[] result = new int[val.length() + 1];
		result[0] = -1;
		while (i < val.length()) {
			while (j >= 0 && val.charAt(j) != val.charAt(i)) {
				j = result[j];
			}
			j++;
			i++;
			result[i] = j;
		}
		return result;

	}

	public static boolean nextPer(int[] data) {
		int i = data.length - 1;
		while (i > 0 && data[i] < data[i - 1]) {
			i--;
		}
		if (i == 0) {
			return false;
		}
		int j = data.length - 1;
		while (data[j] < data[i - 1]) {
			j--;
		}
		int temp = data[i - 1];
		data[i - 1] = data[j];
		data[j] = temp;
		Arrays.sort(data, i, data.length);
		return true;
	}

	public static int digit(long n) {
		int result = 0;
		while (n > 0) {
			n /= 10;
			result++;
		}
		return result;
	}

	public static double dist(long a, long b, long x, long y) {
		double val = (b - a) * (b - a) + (x - y) * (x - y);
		val = Math.sqrt(val);
		double other = x * x + a * a;
		other = Math.sqrt(other);
		return val + other;

	}

	public static class Point implements Comparable<Point> {

		int x, y;

		public Point(int start, int end) {
			this.x = start;
			this.y = end;
		}

		@Override
		public int hashCode() {
			int hash = 5;
			hash = 47 * hash + this.x;
			hash = 47 * hash + this.y;
			return hash;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			final Point other = (Point) obj;
			if (this.x != other.x) {
				return false;
			}
			if (this.y != other.y) {
				return false;
			}
			return true;
		}

		@Override
		public int compareTo(Point o) {
			return Integer.compare(x, o.x);
		}
	}

	public static class FT {

		long[] data;

		FT(int n) {
			data = new long[n];
		}

		public void update(int index, long value) {
			while (index < data.length) {
				data[index] += value;
				index += (index & (-index));
			}
		}

		public long get(int index) {
			long result = 0;
			while (index > 0) {
				result += data[index];
				index -= (index & (-index));
			}
			return result;

		}
	}

	public static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	public static long pow(long a, long b) {
		if (b == 0) {
			return 1;
		}
		if (b == 1) {
			return a;
		}
		long val = pow(a, b / 2);
		if (b % 2 == 0) {
			return val * val % MOD;
		} else {
			return val * (val * a % MOD) % MOD;

		}
	}

	static class Scanner {

		BufferedReader br;
		StringTokenizer st;

		public Scanner() throws FileNotFoundException {
			// System.setOut(new PrintStream(new
			// BufferedOutputStream(System.out), true));
			br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new
			// FileInputStream(new File("input.txt"))));
		}

		public String next() {

			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					throw new RuntimeException();
				}
			}
			return st.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			st = null;
			try {
				return br.readLine();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}

		public boolean endLine() {
			try {
				String next = br.readLine();
				while (next != null && next.trim().isEmpty()) {
					next = br.readLine();
				}
				if (next == null) {
					return true;
				}
				st = new StringTokenizer(next);
				return st.hasMoreTokens();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}
	}
}

import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n=in.nextInt(),k=in.nextInt(),out=0;
		Vector<Integer> books = new Vector<Integer>(),p=new Vector<Integer>();
		for (;n>0;n--) {p.add(in.nextInt());}
		while (!p.isEmpty()) {
			if (!books.contains(p.elementAt(0))) {
				out++;
				books.add(p.elementAt(0));
				if (books.size()>k) {
					@SuppressWarnings("unchecked")
					Vector<Integer> use = (Vector<Integer>) books.clone();
					int last=0;
					for (int z:p) {
						if (use.contains(z)) {
							use.removeElement(z);
							last = z;
						}
					}
					if (use.isEmpty()) {
						books.remove(last);
					} else {
						books.remove(use.elementAt(0));
					}
				}
			}
			p.removeElementAt(0);
		}
		System.out.println(out);
		in.close();
 	}
}

import java.io.*;
import java.util.*;

public class h {
    public static void main (String[] args) {
        Scanner s = new Scanner(System.in);

        int n = s.nextInt(), k = s.nextInt();
        Book[] a = new Book[n];
        freq = new int[100];
        next = new int[100];

        Arrays.fill(next, 100100);
        int[] t = new int[n];

        for(int i = 0; i < n; i++) {
            int x = s.nextInt();
            t[i] = x;
            freq[x]++;
            next[x] = i;
        }

        for(int i  =0; i < n; i++) a[i] = new Book(t[i], freq[t[i]]);

        int res = 0;
        ArrayList<Book> list = new ArrayList<>();

        boolean[] have = new boolean[100];
        int cap = 0;
        for(int i = 0; i < n; i++) {
            if(cap < k) {
                if(!have[t[i]]) {
                    have[t[i]] = true;
                    cap++;
                    res++;
                    list.add(a[i]);
                }
            } else {
//                    System.out.println("!");
                if(!have[t[i]]) {
                    Collections.sort(list);
                    Book rem = list.remove(0);
                    have[rem.num] = false;
                    cap--;

                    have[t[i]] = true;
                    cap++;
                    list.add(a[i]);
                    res++;

                } else {

                }

            }
            freq[t[i]]--;
//            System.out.println("R "  + res);
//            System.out.println(Arrays.toString(Arrays.copyOfRange(have, 0, 4)));
        }

        System.out.println(res);

    }

    static int[] freq;
    static int[] next;

    static class Book implements Comparable<Book> {
        int num, ft;
        Book(int x, int f) {
            num = x; ft = f;
        }
        public int compareTo(Book o) {
            if(freq[num] == freq[o.num]) {
                return Integer.compare(next[num], next[o.num]);
            }
            return Integer.compare(freq[num], freq[o.num]);
        }
    }
}

import java.util.*;
import java.io.*;
import java.math.*;

public class TestClass
{
	public static void main(String[] args) throws Exception
	{
		//InputReader in = new InputReader(System.in);
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		String s[] = in.readLine().split(" ");
		long n= Long.parseLong(s[0]);
		long cap=Long.parseLong(s[1]);

		int[] q=new int[(int) n];
		boolean[] a=new boolean[((int) n +1)];
		String s1[] = in.readLine().split(" ");
		for(int i=0;i<n;i++)
		{
			q[i]=Integer.parseInt(s1[i]);
		}
		int chf=0,c=0;

		for(int i=0;i<n;i++)
		{
			if(a[q[i]])continue;

			else
			{
				chf++;
				c++;
				a[q[i]]=true;

				if(c>cap)
				{
					x: for(int j=0;j<i;j++)
					{
						if(a[q[j]])
						{
							int temp=0;
						for(int k=i+1;k<n;k++)
						{
							if(q[j]==q[k])
							{
								temp++;
							}
						}
							if(temp==0){a[q[j]]=false;c--;break x;}
						}
					}

					if(c>cap)
					{
						int l=0;
						while(q[l]==q[i])l++;
						a[q[l]]=false;
						c--;
					}
				}
			}
		}
		out.println(chf);
		out.close();
	}

}

import java.util.*;
import java.io.*;
import java.math.*;

public class TestClass
{
	public static void main(String[] args) throws Exception
	{
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);

		long n=in.nextLong();
		long cap=in.nextLong();

		int[] q=new int[(int) n];
		boolean[] a=new boolean[((int) n +1)];

		for(int i=0;i<n;i++)
		{
			q[i]=in.nextInt();
		}
		int chf=0,c=0;

		for(int i=0;i<n;i++)
		{
			if(a[q[i]])continue;

			else
			{
				chf++;
				c++;
				a[q[i]]=true;

				if(c>cap)
				{
					x: for(int j=0;j<i;j++)
					{
						if(a[q[j]])
						{
							int temp=0;
						for(int k=i+1;k<n;k++)
						{
							if(q[j]==q[k])
							{
								temp++;
							}
						}
							if(temp==0){a[q[j]]=false;c--;break x;}
						}
					}

					if(c>cap)
					{
						int l=0;
						while(q[l]==q[i])l++;
						a[q[l]]=false;
						c--;
					}
				}
			}
		}
		out.println(chf);out.flush();
	}

}
class InputReader{
	private final InputStream stream;
	private final byte[] buf=new byte[1024];
	private int curChar;
	private int numChars;
	public InputReader(InputStream stream){this.stream=stream;}
	private int read()throws IOException{
		if(curChar>=numChars){
			curChar=0;
			numChars=stream.read(buf);
			if(numChars<=0)
				return -1;
		}
		return buf[curChar++];
	}
	public final int nextInt()throws IOException{return (int)nextLong();}
	public final long nextLong()throws IOException{
		int c=read();
		while(isSpaceChar(c)){
			c=read();
			if(c==-1) throw new IOException();
		}
		boolean negative=false;
		if(c=='-'){
			negative=true;
			c=read();
		}
		long res=0;
		do{
			if(c<'0'||c>'9')throw new InputMismatchException();
			res*=10;
			res+=(c-'0');
			c=read();
		}while(!isSpaceChar(c));
		return negative?(-res):(res);
	}
	public final int[] readIntBrray(int size)throws IOException{
		int[] arr=new int[size];
		for(int i=0;i<size;i++)arr[i]=nextInt();
		return arr;
	}
	public final String next()throws IOException{
		int c=read();
		while(isSpaceChar(c))c=read();
		StringBuilder res=new StringBuilder();
		do{
			res.append((char)c);
			c=read();
		}while(!isSpaceChar(c));
		return res.toString();
	}
	public final String nextLine()throws IOException{
		int c=read();
		while(isSpaceChar(c))c=read();
		StringBuilder res=new StringBuilder();
		do{
			res.append((char)c);
			c=read();
		}while(c!='\n'&&c!=-1);
		return res.toString();
	}
	private boolean isSpaceChar(int c){
		return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
	}

}

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

public class Hiedi_and_library {
    public static void main(String[] a){
        Scanner sc=new Scanner(System.in);
      int n=sc.nextInt();
      int c=sc.nextInt();
      int cost=0;
      ArrayList ar=new ArrayList();
     ArrayList cr=new ArrayList();
      for(int i=0;i<n;i++){
      ar.add(sc.nextInt());
      }

      Iterator i=ar.listIterator();

      while(i.hasNext()){
          int v=(int)i.next();
      if(!cr.contains(v) && (cr.size()!=c)){
      cr.add(v);
      cost=cost+1;
      i.remove();
      }
      else if(!cr.contains(v) && (cr.size()==c)){
      Iterator j=cr.listIterator();
      int max=0;
      int notexist=0;
      while(j.hasNext()){
          int t=(int)j.next();
          if((int)ar.indexOf(t)==-1){
          max=cr.indexOf(t);
          notexist=1;
          }
          if((int)ar.indexOf(t)>max && j.hasNext() && ((int)ar.indexOf(t))!=-1){
      max=ar.indexOf(t);
              }
      }
     // int replace=(int)ar.get(max);

     if(max==0 || notexist==1){cr.set(max,v);}
     else{
      int index=cr.indexOf(ar.get(max));
      cr.set(index,v);}
      cost=cost+1;
      i.remove();
      }

      }
      System.out.println(cost);
    }

}

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

public class Hiedi_and_library {
    public static void main(String[] a){
        Scanner sc=new Scanner(System.in);
      int n=sc.nextInt();
      int c=sc.nextInt();
      int cost=0;
      ArrayList ar=new ArrayList();
     ArrayList cr=new ArrayList();
      for(int i=0;i<n;i++){
      ar.add(sc.nextInt());
      }

      Iterator i=ar.listIterator();

      while(i.hasNext()){
          int v=(int)i.next();
      if(!cr.contains(v) && (cr.size()!=c)){
      cr.add(v);
      cost=cost+1;

      }
      else if(!cr.contains(v) && (cr.size()==c)){
      Iterator j=cr.listIterator();
      int max=0;
      int notexist=0;
      while(j.hasNext()){
          int t=(int)j.next();
          if((int)ar.indexOf(t)==-1){
          max=cr.indexOf(t);
          notexist=1;
          }
          if((int)ar.indexOf(t)>max && j.hasNext() && ((int)ar.indexOf(t))!=-1){
      max=ar.indexOf(t);
              }
      }
     // int replace=(int)ar.get(max);

     if(max==0 || notexist==1){cr.set(max,v);}
     else{
      int index=cr.indexOf(ar.get(max));
      cr.set(index,v);}

      }
      i.remove();
      }
      System.out.println(cost);
    }

}

import java.util.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;

public class TestClass implements Runnable
{
	/*int x,y;
	public TestClass(int x,int y)
	{
		this.x=x;
		this.y=y;
	}*/
	public static void main(String args[]) throws Exception
	{
		new Thread(null, new TestClass(),"TESTCLASS",1<<18).start();
	}
	public void run()
	{
		//Scanner scan=new Scanner(System.in);
		InputReader hb=new InputReader(System.in);
		PrintWriter w=new PrintWriter(System.out);

		int n=hb.nextInt();
		int k=hb.nextInt();

		ArrayList<Integer> list=new ArrayList<>();
		for(int i=0;i<n;i++)
			list.add(hb.nextInt());

		HashSet<Integer> books=new HashSet<Integer>();
		int count=0;
		int price=0;
		for(int i=0;i<n;i++)
		{
			//for(int l:books)
			//	w.print(l+" ");
			//w.println();
			if(books.contains(list.get(i)))
				continue;
			else if(count<k)
			{
				books.add(list.get(i));
			}
			else
			{
				int index=-1;
				int last=-1;
				int flag=0;
				int flag1=0;
				int book=0;
				for(int b:books)
				{
					for(int j=list.size()-1;j>i;j--)
					{
						//w.println("Inner: "+b+" "+list.get(j));
						if(list.get(j)==b)
						{
							index=j;
							flag=1;
							break;
						}
					}
					if(index>last)
						last=index;
					//w.println("Last: "+last+"  Flag: "+flag);
					if(flag==0)
					{
						flag1=1;
						book=b;
						break;
					}
					else
						flag=0;
				}
				if(flag1==1)
					books.remove(book);
				else
					books.remove(list.get(last));

				books.add(list.get(i));
			}
			price++;
			count++;
		}
		w.print(price);
		w.close();
	}

	private void shuffle(int[] arr)
	{
		Random ran = new Random();
		for (int i = 0; i < arr.length; i++) {
			int i1 = ran.nextInt(arr.length);
			int i2 = ran.nextInt(arr.length);

			int temp = arr[i1];
			arr[i1] = arr[i2];
			arr[i2] = temp;
		}
	}

	static class DSU
	{
		int parent[];
		int sizeParent[];
		DSU(int n)
		{
			parent=new int[n];
			sizeParent=new int[n];
			Arrays.fill(sizeParent,1);
			for(int i=0;i<n;i++)
				parent[i]=i;
		}

		int find(int x)
		{
			if(x!=parent[x])
				parent[x]=find(parent[x]);
			return parent[x];
		}

		void union(int x,int y)
		{
			x=find(x);
			y=find(y);
			if(sizeParent[x]>=sizeParent[y])
			{
				if(x!=y)
					sizeParent[x]+=sizeParent[y];
				parent[y]=x;
			}
			else
			{
				if(x!=y)
					sizeParent[y]+=sizeParent[x];
				parent[x]=y;
			}
		}
	}

	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars==-1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}

				if(numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine()
		{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
		public int nextInt()
		{
			int c = read();

			while(isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;
			do
			{
				if(c<'0'||c>'9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			long res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));
				return res * sgn;
		}

		public double nextDouble()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.')
			{
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.')
			{
				c = read();
				double m = 1;
				while (!isSpaceChar(c))
				{
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public String readString()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = read();
			}
			while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next()
		{
			return readString();
		}

		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}
	}

	static class Pair implements Comparable<Pair>
	{
		int a;
		int b;
		String str;
		public Pair(int a,int b)
		{
			this.a=a;
			this.b=b;
			str=min(a,b)+" "+max(a,b);
		}

		public int compareTo(Pair pair)
		{
			if(Integer.compare(a,pair.a)==0)
				return Integer.compare(b,pair.b);

			return Integer.compare(a,pair.a);
		}
	}

}

import java.util.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;

public class TestClass implements Runnable
{
	/*int x,y;
	public TestClass(int x,int y)
	{
		this.x=x;
		this.y=y;
	}*/
	public static void main(String args[]) throws Exception
	{
		new Thread(null, new TestClass(),"TESTCLASS",1<<18).start();
	}
	public void run()
	{
		//Scanner scan=new Scanner(System.in);
		InputReader hb=new InputReader(System.in);
		PrintWriter w=new PrintWriter(System.out);

		int n=hb.nextInt();
		int k=hb.nextInt();

		ArrayList<Integer> list=new ArrayList<>();
		for(int i=0;i<n;i++)
			list.add(hb.nextInt());

		HashSet<Integer> books=new HashSet<Integer>();
		int price=0;
		for(int i=0;i<n;i++)
		{
			for(int l:books)
				w.print(l+" ");
			w.println();
			if(books.contains(list.get(i)))
				continue;
			if(books.size()<k)
			{
				books.add(list.get(i));
			}
			else
			{
				int flag=0;
				int flag1=0;
				for(int b:books)
				{
					for(int j=i+1;j<list.size();j++)
					{
						//w.println("Inner: "+b+" "+list.get(j));
						if(list.get(j)==b)
						{
							flag=1;
							break;
						}
					}
					if(flag==0)
					{
						books.remove(b);
						books.add(list.get(i));
						flag1=1;
						break;
					}

				}
				if(flag1==0)
				{
					HashSet<Integer> temp=new HashSet<>();
					for(int x:books)
						temp.add(x);

					for(int j=i;j<n;j++)
					{
						if(temp.size()<=1)
							break;

						if(temp.contains(list.get(j)))
							temp.remove(list.get(j));
					}
					for(int x:temp)
						books.remove(x);
					books.add(list.get(i));
				}

			}
			price++;
		}
		w.print(price);
		w.close();
	}

	private void shuffle(int[] arr)
	{
		Random ran = new Random();
		for (int i = 0; i < arr.length; i++) {
			int i1 = ran.nextInt(arr.length);
			int i2 = ran.nextInt(arr.length);

			int temp = arr[i1];
			arr[i1] = arr[i2];
			arr[i2] = temp;
		}
	}

	static class DSU
	{
		int parent[];
		int sizeParent[];
		DSU(int n)
		{
			parent=new int[n];
			sizeParent=new int[n];
			Arrays.fill(sizeParent,1);
			for(int i=0;i<n;i++)
				parent[i]=i;
		}

		int find(int x)
		{
			if(x!=parent[x])
				parent[x]=find(parent[x]);
			return parent[x];
		}

		void union(int x,int y)
		{
			x=find(x);
			y=find(y);
			if(sizeParent[x]>=sizeParent[y])
			{
				if(x!=y)
					sizeParent[x]+=sizeParent[y];
				parent[y]=x;
			}
			else
			{
				if(x!=y)
					sizeParent[y]+=sizeParent[x];
				parent[x]=y;
			}
		}
	}

	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars==-1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}

				if(numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine()
		{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
		public int nextInt()
		{
			int c = read();

			while(isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;
			do
			{
				if(c<'0'||c>'9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			long res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));
				return res * sgn;
		}

		public double nextDouble()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.')
			{
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.')
			{
				c = read();
				double m = 1;
				while (!isSpaceChar(c))
				{
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public String readString()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = read();
			}
			while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next()
		{
			return readString();
		}

		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}
	}

	static class Pair implements Comparable<Pair>
	{
		int a;
		int b;
		String str;
		public Pair(int a,int b)
		{
			this.a=a;
			this.b=b;
			str=min(a,b)+" "+max(a,b);
		}

		public int compareTo(Pair pair)
		{
			if(Integer.compare(a,pair.a)==0)
				return Integer.compare(b,pair.b);

			return Integer.compare(a,pair.a);
		}
	}

}

import java.util.*;
import java.io.*;

public class Library {
    public static void main(String [] args) {
        Reader in = new Reader ();
        Writer out = new Writer ();
        int n = in.nextInt();
        int k = in.nextInt();

        int [] a = new int [n + 5];
        for(int i = 1; i <= n; i++) {
            a[i] = in.nextInt();
        }

        int ans = 0;
        TreeSet <Integer> t = new TreeSet <> ();
        int [] cnt = new int [n + 5];
        for(int i = 1; i <= n; i++) {
            cnt[a[i]] += 1;
        }
        for(int i = 1; i <= n; i++) {
            cnt[a[i]] -= 1;
            if(!t.contains(a[i])) {
                int good = t.isEmpty() ? -1 : t.first();
                ++ans;
                t.add(a[i]);
                if(t.size() > k) {
                    for(Integer j : t) {
                        if(j == a[i]) continue;
                        if(cnt[j] < cnt[good]) {
                            good = j;
                        }
                    }
                    t.remove(good);
                }
            }
        }
        System.out.println(ans);
    }
    static class Reader {
        private StringTokenizer a;
        private BufferedReader b;
        Reader () {
            a = null;
            b = new BufferedReader (new InputStreamReader (System.in));
        }
        public String next () {
            while(a == null || !a.hasMoreTokens()) {
                try {
                    a = new StringTokenizer (b.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return a.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(this.next());
        }
        public long nextLong () {
            return Long.parseLong(this.next());
        }
        public double nextDouble () {
            return Double.parseDouble(this.next());
        }
        public String nextLine() {
            try {
                return b.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return "";
        }
    }
    static class Writer {
        private PrintWriter a;
        private StringBuffer b;
        Writer () {
            a = new PrintWriter (System.out);
            b = new StringBuffer ("");
        }
        public void write (Object s) {
            b.append(s);
        }
        public void writeln(Object s) {
            b.append(s).append('\n');
        }
        public void flush () {
            a.print(b);
            a.flush();
            a.close();
        }
    }
    static class Pair implements Comparator <Pair> {
        int first;
        int second;
        Pair  (int a, int b) {
            this.first = a;
            this.second = b;
        }
        Pair (Pair a) {
            this.first = a.first;
            this.second = a.second;
        }
        Pair () {}
        public String toString () {
            return "[" + first + ", " + second + "]";
        }
        public int compare (Pair a, Pair b) {
            if(a.first == b.first) {
                return a.second - b.second;
            } else {
                return a.first - b.first;
            }
        }
    }
}

import java.util.*;
import java.io.*;

public class Library {
    public static void main(String [] args) {
        Reader in = new Reader ();
        Writer out = new Writer ();
        int n = in.nextInt();
        int k = in.nextInt();

        int [] a = new int [n + 5];
        for(int i = 1; i <= n; i++) {
            a[i] = in.nextInt();
        }

        int ans = 0;
        TreeSet <Integer> t = new TreeSet <> ();
        int [] cnt = new int [n + 5];
        for(int i = 1; i <= n; i++) {
            cnt[a[i]] += 1;
        }
        for(int i = 1; i <= n; i++) {
            cnt[a[i]] -= 1;
            if(!t.contains(a[i])) {
                int good = t.isEmpty() ? -1 : t.first();
                ++ans;
                t.add(a[i]);
                if(t.size() > k) {
                    for(Integer j : t) {
                        if(j == a[i]) continue;
                        if(cnt[j] == 0) good = j;
                    }
                    t.remove(good);
                }
            }
        }
        System.out.println(ans);
    }
    static class Reader {
        private StringTokenizer a;
        private BufferedReader b;
        Reader () {
            a = null;
            b = new BufferedReader (new InputStreamReader (System.in));
        }
        public String next () {
            while(a == null || !a.hasMoreTokens()) {
                try {
                    a = new StringTokenizer (b.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return a.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(this.next());
        }
        public long nextLong () {
            return Long.parseLong(this.next());
        }
        public double nextDouble () {
            return Double.parseDouble(this.next());
        }
        public String nextLine() {
            try {
                return b.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return "";
        }
    }
    static class Writer {
        private PrintWriter a;
        private StringBuffer b;
        Writer () {
            a = new PrintWriter (System.out);
            b = new StringBuffer ("");
        }
        public void write (Object s) {
            b.append(s);
        }
        public void writeln(Object s) {
            b.append(s).append('\n');
        }
        public void flush () {
            a.print(b);
            a.flush();
            a.close();
        }
    }
    static class Pair implements Comparator <Pair> {
        int first;
        int second;
        Pair  (int a, int b) {
            this.first = a;
            this.second = b;
        }
        Pair (Pair a) {
            this.first = a.first;
            this.second = a.second;
        }
        Pair () {}
        public String toString () {
            return "[" + first + ", " + second + "]";
        }
        public int compare (Pair a, Pair b) {
            if(a.first == b.first) {
                return a.second - b.second;
            } else {
                return a.first - b.first;
            }
        }
    }
}

import java.util.*;

import java.io.*;

public class Main
{

	public static void main(String[] args) throws IOException
	{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer s = new StringTokenizer(br.readLine());
		int n=Integer.parseInt(s.nextToken());
		int k=Integer.parseInt(s.nextToken());

		s = new StringTokenizer(br.readLine());
		int ar[]=new int[n];
		int freq[]=new int[81];
		int last[]=new int[81];
		for(int i=0;i<ar.length;i++) {
			ar[i]=Integer.parseInt(s.nextToken());
			freq[ar[i]]++;
			last[ar[i]]=i;
		}
		int count=0;
		for(int i=1;i<=80;i++) {
			if(freq[i]>0)
				count++;
		}
		if(count<=k) {
			pw.println(count);
			pw.close();
		}
		Set<Integer>hm=new HashSet<>();
		int ans=0;
		PriorityQueue<int[]>pq=new PriorityQueue<>((a,b)-> a[1]-b[1]);
		for(int i=0;i<ar.length;i++) {
			if(pq.size()<k) {
				if(!hm.contains(ar[i])) {
					hm.add(ar[i]);
					ans++;
					pq.add(new int[] {ar[i],last[i]});
				}

			}else {
				if(!hm.contains(ar[i])) {
					ans++;
					pq.poll();
					hm.remove(ar[i]);
				}
			}
		}
		pw.println(ans);

		pw.close();

	}

}

import java.util.*;

import java.io.*;

public class Main
{

	public static void main(String[] args) throws IOException
	{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer s = new StringTokenizer(br.readLine());
		int n=Integer.parseInt(s.nextToken());
		int k=Integer.parseInt(s.nextToken());

		s = new StringTokenizer(br.readLine());
		int ar[]=new int[n];
		int freq[]=new int[81];
		int last[]=new int[81];
		for(int i=0;i<ar.length;i++) {
			ar[i]=Integer.parseInt(s.nextToken());
			freq[ar[i]]++;
			last[ar[i]]=i;
		}
		int count=0;
		for(int i=1;i<=80;i++) {
			if(freq[i]>0)
				count++;
		}
		if(count<=k) {
			pw.println(count);
			pw.close();
		}
		Set<Integer>hm=new HashSet<>();
		int ans=0;
		PriorityQueue<int[]>pq=new PriorityQueue<>((a,b)-> a[1]-b[1]);
		for(int i=0;i<ar.length;i++) {
			if(pq.size()<k) {
				if(!hm.contains(ar[i])) {
					hm.add(ar[i]);
					ans++;
					pq.add(new int[] {ar[i],last[ar[i]]});
				}

			}else {
				if(!hm.contains(ar[i])) {
					ans++;
					int val=pq.poll()[0];
					hm.remove(val);
					pq.add(new int[] {ar[i],last[ar[i]]});
					hm.add(ar[i]);
				}
			}
		}
		pw.println(ans);

		pw.close();

	}

}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.lang.StringBuilder;
import java.util.*;
import java.lang.Math;

public class CFHelveticA {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = scanner.nextInt();
        int k = scanner.nextInt();

        int[] a = new int[n];
        for (int ii = 0; ii < n; ii++) a[ii] = scanner.nextInt();

        int[][] rcount = new int[n+1][n+1];
        for (int kk = 1; kk <= n; kk++) {
            rcount[kk][n] = 0;
            for (int ii = n-1; ii >= 0; ii--) {
                rcount[kk][ii] = rcount[kk][ii+1] + (kk == a[ii] ? 1 : 0);
            }
        }

        int ans = 0;
        ArrayList<Integer> books = new ArrayList<Integer>();
        for (int ii = 0; ii < n; ii++) {
            if (!books.contains(a[ii])) {
                if (books.size() >= k) {
                    int jjfewest = -1;
                    for (int jj = 0; jj < books.size(); jj++) {
                        if (jjfewest == -1 || rcount[(int)books.get(jj)][ii] < rcount[(int)books.get(jjfewest)][ii]) {
                            jjfewest = jj;
                        }
                    }
                    books.remove(jjfewest);
                }
                books.add(a[ii]);
                ans++;
            }
        }

        writer.write(ans + "\n");
        writer.flush();
    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

/**
 *
 * @author Harsh Vardhan Kumar
 */
public class newMain1 {
    public static boolean eof = false ;
    static Set<Book> library ;
    static int k ;
    static int [] requirement ;
    public static void main(String[] args) {
        Reader in = new Reader(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), true) ;

        int n = in.nextInt() ;
        k  = in.nextInt() ;
        int chf = 0 ;
        library = new HashSet<>(k);

        requirement = new int[n+1] ;
        int[] bookre = new int[n] ;
        Arrays.fill(requirement, Integer.MAX_VALUE);
        for(int i =  0 ; i<n ; i++) {
            int bookno = in.nextInt() ;
            bookre[i] = bookno ;
            if(requirement[bookno]!=Integer.MAX_VALUE) {
                requirement[bookno]++ ;
            }
            else if(requirement[bookno]==Integer.MAX_VALUE) {
                requirement[bookno] = 1 ;
            }
        }

        //System.out.println(Arrays.toString(requirement));

        for(int a : bookre) {
            Book book = new Book(a) ;
            //System.out.println("book is "+book.valuenumber);
            if(!library.contains(book)) {
                //System.out.println("not available "+book.valuenumber);
                if(isPlaceAvailable()) {
                    //System.out.println("place is available");
                    chf++ ;
                    library.add(book) ;
                }
                else if(!isPlaceAvailable()) {
                    Book removed = booktoberemoved() ;

                    //System.out.println("removed book is "+removed.valuenumber);
                    library.remove(removed) ;
                    chf++ ;
                    library.add(book);
                }
                requirement[book.valuenumber]-- ;
            }
            else {
                requirement[book.valuenumber]-- ;
            }
        }

        System.out.println(chf);

    }
    private static boolean isPlaceAvailable() {
        return library.size()!=k ;
    }
    private static Book booktoberemoved() {
        int min = Integer.MAX_VALUE ;
        Book r = null ;
        for(Book book : library) {
            if(min>requirement[book.valuenumber]) {
                min = requirement[book.valuenumber] ;
                r = book ;
            }
        }
        if(r!=null) {
            requirement[r.valuenumber]-- ;
        }
        return r ;
    }
    static class Reader {
        private static BufferedReader b ;
        public static String line ;
        public Reader() {
        }

        public Reader(BufferedReader b) {
            this.b = b ;
        }
        private static StringTokenizer st = null;
        public static String next()  {

            if(st==null || !st.hasMoreElements()) {
                try {
                    line = b.readLine() ;
                    if(line==null) {
                        eof = true ;
                        return null ;
                    }
                    else {
                        st=new StringTokenizer(line);
                    }
                } catch (IOException ex) {

                }
            }
            return st.nextToken() ;
        }
        public static String nextLine()  {
            try {
                return b.readLine() ;
            } catch (IOException ex) {

            }
            return line ;
        }
        public static int nextInt()  {
            return Integer.parseInt(next());
        }
        public static long nextLong()  {
            return Long.parseLong(next());
        }
        public static float nextFloat()  {
            return Float.parseFloat(next());
        }
        public void close() throws IOException {
            b.close() ;
        }

    }
    static class Book {
        int valuenumber ;

        public Book(int valuenumber) {
            this.valuenumber = valuenumber;
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Book other = (Book) obj;
            if (this.valuenumber != other.valuenumber) {
                return false;
            }
            return true;
        }
        public int hashCode() {
            return valuenumber ;
        }
    }
}

import java.util.Scanner;
import java.util.Arrays;

public class HeidiAndLibraryEasy {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();

		boolean[] cap = new boolean[n + 1];
		int[] books = new int[n + 1];
		int[] booksCounter = new int[n + 1];
		int cost = 0;

		for (int ii = 1; ii <= n; ii++) {
			books[ii] = in.nextInt();
			booksCounter[books[ii]]++;
		}

		// System.out.println(Arrays.toString(booksCounter));

		for (int ii = 1; ii <= n; ii++) {
			int book = books[ii];

			// book not found
			if (cap[book] == false) {

				// check capacity
				// System.out.println("books counter: " + countBooks(cap));
				if (countBooks(cap) == k) {
					// System.out.println(findMin(booksCounter));
					cap[findMin(booksCounter)] = false;
				}

				// buy book
				cost++;
				cap[book] = true;
				// System.out.println(Arrays.toString(cap));
			}
		}
		System.out.println(cost);
	}

	private static int findMin(int[] booksCounter) {
		int min = 999;
		int minIdx = -1;
		for (int ii = 1; ii < booksCounter.length; ii++) {
			if (booksCounter[ii] < min && booksCounter[ii] > 0) {
				min = booksCounter[ii];
				minIdx = ii;
			}
		}

		// System.out.println("Least demanded: " + min + " at index " + minIdx);
		return minIdx;
	}

	private static int countBooks(boolean[] books) {
		int res = 0;
		for (int ii = 0; ii < books.length; ii++) {
			if (books[ii] == true) res++;
		}

		return res;
	}
}

import java.util.Scanner;
import java.util.Arrays;

public class HeidiAndLibraryEasy {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();

		boolean[] cap = new boolean[n + 1];
		int[] books = new int[n + 1];
		int cost = 0;

		for (int ii = 1; ii <= n; ii++) {
			books[ii] = in.nextInt();
		}

		// System.out.println(Arrays.toString(booksCounter));

		for (int ii = 1; ii <= n; ii++) {
			int book = books[ii];

			// book not found
			if (cap[book] == false) {

				// check capacity
				// System.out.println("books counter: " + countBooks(cap));
				if (countBooks(cap) >= k) {
					// System.out.println(countBooks(cap) + "," + k);
					cap[findFarthestDemanded(cap, Arrays.copyOfRange(books, ii, books.length))] = false;
				}

				// buy book
				cost++;
				cap[book] = true;
				// System.out.println(Arrays.toString(cap));
			}
		}
		System.out.println(cost);
	}

	private static int findFarthestDemanded(boolean[] cap, int[] inBooks) {
		int[] demands = new int[cap.length];

		for (int ii = 1; ii < cap.length; ii++) {
			if (cap[ii] == false) continue;

			int firstDemandIdx = 999;
			for (int jj = 0; jj < inBooks.length; jj++) {
				if (ii == inBooks[jj]) firstDemandIdx = jj;
			}
			demands[ii] = firstDemandIdx;
		}

		int max = -1;
		for (int ii = 1; ii < demands.length; ii++) {
			if (demands[ii] > max) max = ii;
		}

		return max;
	}

	private static int countBooks(boolean[] books) {
		int res = 0;
		for (int ii = 0; ii < books.length; ii++) {
			if (books[ii] == true) res++;
		}

		return res;
	}
}

import java.util.Scanner;
import java.util.Arrays;

public class HeidiAndLibraryEasy {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();

		boolean[] cap = new boolean[n + 1];
		int[] books = new int[n + 1];
		int[] booksCounter = new int[n + 1];
		int cost = 0;
		int lastInserted = -1;

		for (int ii = 1; ii <= n; ii++) {
			books[ii] = in.nextInt();
			booksCounter[books[ii]]++;
		}

		// System.out.println(Arrays.toString(booksCounter));

		for (int ii = 1; ii <= n; ii++) {
			int book = books[ii];

			// book not found
			if (cap[book] == false) {

				// check capacity
				// System.out.println("books counter: " + countBooks(cap));
				if (countBooks(cap) >= k) {
					// System.out.println(countBooks(cap) + "," + k);
					cap[lastInserted] = false;
				}

				// buy book
				cost++;
				cap[book] = true;
				lastInserted = book;
				// System.out.println(Arrays.toString(cap));
			}
		}
		System.out.println(cost);
	}

	private static int findMin(int[] booksCounter) {
		int min = 999;
		int minIdx = -1;
		for (int ii = 1; ii < booksCounter.length; ii++) {
			if (booksCounter[ii] < min && booksCounter[ii] > 0) {
				min = booksCounter[ii];
				minIdx = ii;
			}
		}

		// System.out.println("Least demanded: " + min + " at index " + minIdx);
		return minIdx;
	}

	private static int countBooks(boolean[] books) {
		int res = 0;
		for (int ii = 0; ii < books.length; ii++) {
			if (books[ii] == true) res++;
		}

		return res;
	}
}

import java.util.Scanner;
import java.util.Arrays;

public class HeidiAndLibraryEasy {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();

		boolean[] cap = new boolean[n + 1];
		int[] books = new int[n + 1];
		int[] booksCounter = new int[n + 1];
		int cost = 0;
		int lastInserted = -1;

		for (int ii = 1; ii <= n; ii++) {
			books[ii] = in.nextInt();
			booksCounter[books[ii]]++;
		}

		// System.out.println(Arrays.toString(booksCounter));

		for (int ii = 1; ii <= n; ii++) {
			int book = books[ii];

			// book not found
			if (cap[book] == false) {

				// check capacity
				// System.out.println("books counter: " + countBooks(cap));
				if (countBooks(cap) >= k) {
					// System.out.println(countBooks(cap) + "," + k);
					cap[lastInserted] = false;
				}

				// buy book
				cost++;
				cap[book] = true;
				lastInserted = book;
				// System.out.println(Arrays.toString(cap));
			}
		}
		// System.out.println(cost);
	}

	private static int findMin(int[] booksCounter) {
		int min = 999;
		int minIdx = -1;
		for (int ii = 1; ii < booksCounter.length; ii++) {
			if (booksCounter[ii] < min && booksCounter[ii] > 0) {
				min = booksCounter[ii];
				minIdx = ii;
			}
		}

		// System.out.println("Least demanded: " + min + " at index " + minIdx);
		return minIdx;
	}

	private static int countBooks(boolean[] books) {
		int res = 0;
		for (int ii = 0; ii < books.length; ii++) {
			if (books[ii] == true) res++;
		}

		return res;
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.Random;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            int k = in.readInt();
            IntHashSet setA = new IntHashSet();
            IntHashSet setB = new IntHashSet();
            int answer = 0;
            for (int i = 0; i < n; i++) {
                int ai = in.readInt();

                if (setB.size() == k) {
                    setA = new IntHashSet();
                    setA.addAll(setB);
                    setB = new IntHashSet();
                }

                if (setB.contains(ai)) {

                } else if (setA.contains(ai)) {
                    setA.remove(ai);
                    setB.add(ai);
                } else {
                    setB.add(ai);
                    ++answer;
                }

            }

            out.printLine(answer);
        }

    }

    static class IntArray extends IntAbstractStream implements IntList {
        private int[] data;

        public IntArray(int[] arr) {
            data = arr;
        }

        public int size() {
            return data.length;
        }

        public int get(int at) {
            return data[at];
        }

        public void addAt(int index, int value) {
            throw new UnsupportedOperationException();
        }

        public void removeAt(int index) {
            throw new UnsupportedOperationException();
        }

    }

    static interface IntStream extends Iterable<Integer>, Comparable<IntStream> {
        public IntIterator intIterator();

        default public Iterator<Integer> iterator() {
            return new Iterator<Integer>() {
                private IntIterator it = intIterator();

                public boolean hasNext() {
                    return it.isValid();
                }

                public Integer next() {
                    int result = it.value();
                    it.advance();
                    return result;
                }
            };
        }

        default public int compareTo(IntStream c) {
            IntIterator it = intIterator();
            IntIterator jt = c.intIterator();
            while (it.isValid() && jt.isValid()) {
                int i = it.value();
                int j = jt.value();
                if (i < j) {
                    return -1;
                } else if (i > j) {
                    return 1;
                }
                it.advance();
                jt.advance();
            }
            if (it.isValid()) {
                return 1;
            }
            if (jt.isValid()) {
                return -1;
            }
            return 0;
        }

    }

    static interface IntIterator {
        public int value() throws NoSuchElementException;

        public boolean advance();

        public boolean isValid();

    }

    static interface IntCollection extends IntStream {
        public int size();

        default public void add(int value) {
            throw new UnsupportedOperationException();
        }

        default public IntCollection addAll(IntStream values) {
            for (IntIterator it = values.intIterator(); it.isValid(); it.advance()) {
                add(it.value());
            }
            return this;
        }

    }

    static class IntHashSet extends IntAbstractStream implements IntSet {
        private static final Random RND = new Random();
        private static final int[] SHIFTS = new int[4];
        private static final byte PRESENT_MASK = 1;
        private static final byte REMOVED_MASK = 2;
        private int size;
        private int realSize;
        private int[] values;
        private byte[] present;
        private int step;
        private int ratio;

        static {
            for (int i = 0; i < 4; i++) {
                SHIFTS[i] = RND.nextInt(31) + 1;
            }
        }

        public IntHashSet() {
            this(3);
        }

        public IntHashSet(int capacity) {
            capacity = Math.max(capacity, 3);
            values = new int[capacity];
            present = new byte[capacity];
            ratio = 2;
            initStep(capacity);
        }

        public IntHashSet(IntCollection c) {
            this(c.size());
            addAll(c);
        }

        public IntHashSet(int[] arr) {
            this(new IntArray(arr));
        }

        private void initStep(int capacity) {
            step = RND.nextInt(capacity - 2) + 1;
            while (IntegerUtils.gcd(step, capacity) != 1) {
                step++;
            }
        }

        public IntIterator intIterator() {
            return new IntIterator() {
                private int position = size == 0 ? values.length : -1;

                public int value() throws NoSuchElementException {
                    if (position == -1) {
                        advance();
                    }
                    if (position >= values.length) {
                        throw new NoSuchElementException();
                    }
                    if ((present[position] & PRESENT_MASK) == 0) {
                        throw new IllegalStateException();
                    }
                    return values[position];
                }

                public boolean advance() throws NoSuchElementException {
                    if (position >= values.length) {
                        throw new NoSuchElementException();
                    }
                    position++;
                    while (position < values.length && (present[position] & PRESENT_MASK) == 0) {
                        position++;
                    }
                    return isValid();
                }

                public boolean isValid() {
                    return position < values.length;
                }

                public void remove() {
                    if ((present[position] & PRESENT_MASK) == 0) {
                        throw new IllegalStateException();
                    }
                    present[position] = REMOVED_MASK;
                }
            };
        }

        public int size() {
            return size;
        }

        public void add(int value) {
            ensureCapacity((realSize + 1) * ratio + 2);
            int current = getHash(value);
            while (present[current] != 0) {
                if ((present[current] & PRESENT_MASK) != 0 && values[current] == value) {
                    return;
                }
                current += step;
                if (current >= values.length) {
                    current -= values.length;
                }
            }
            while ((present[current] & PRESENT_MASK) != 0) {
                current += step;
                if (current >= values.length) {
                    current -= values.length;
                }
            }
            if (present[current] == 0) {
                realSize++;
            }
            present[current] = PRESENT_MASK;
            values[current] = value;
            size++;
        }

        private int getHash(int value) {
            int hash = IntHash.hash(value);
            int result = hash;
            for (int i : SHIFTS) {
                result ^= hash >> i;
            }
            result %= values.length;
            if (result < 0) {
                result += values.length;
            }
            return result;
        }

        private void ensureCapacity(int capacity) {
            if (values.length < capacity) {
                capacity = Math.max(capacity * 2, values.length);
                rebuild(capacity);
            }
        }

        private void squish() {
            if (values.length > size * ratio * 2 + 10) {
                rebuild(size * ratio + 3);
            }
        }

        private void rebuild(int capacity) {
            initStep(capacity);
            int[] oldValues = values;
            byte[] oldPresent = present;
            values = new int[capacity];
            present = new byte[capacity];
            size = 0;
            realSize = 0;
            for (int i = 0; i < oldValues.length; i++) {
                if ((oldPresent[i] & PRESENT_MASK) == PRESENT_MASK) {
                    add(oldValues[i]);
                }
            }
        }

        public boolean remove(int value) {
            int current = getHash(value);
            while (present[current] != 0) {
                if (values[current] == value && (present[current] & PRESENT_MASK) != 0) {
                    present[current] = REMOVED_MASK;
                    size--;
                    squish();
                    return true;
                }
                current += step;
                if (current >= values.length) {
                    current -= values.length;
                }
            }
            return false;
        }

        public boolean contains(int value) {
            int current = getHash(value);
            while (present[current] != 0) {
                if (values[current] == value && (present[current] & PRESENT_MASK) != 0) {
                    return true;
                }
                current += step;
                if (current >= values.length) {
                    current -= values.length;
                }
            }
            return false;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(int i) {
            writer.println(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static interface IntList extends IntReversableCollection {
        public abstract int get(int index);

        public abstract void addAt(int index, int value);

        public abstract void removeAt(int index);

        default public IntIterator intIterator() {
            return new IntIterator() {
                private int at;
                private boolean removed;

                public int value() {
                    if (removed) {
                        throw new IllegalStateException();
                    }
                    return get(at);
                }

                public boolean advance() {
                    at++;
                    removed = false;
                    return isValid();
                }

                public boolean isValid() {
                    return !removed && at < size();
                }

                public void remove() {
                    removeAt(at);
                    at--;
                    removed = true;
                }
            };
        }

        default public void add(int value) {
            addAt(size(), value);
        }

    }

    static abstract class IntAbstractStream implements IntStream {

        public String toString() {
            StringBuilder builder = new StringBuilder();
            boolean first = true;
            for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
                if (first) {
                    first = false;
                } else {
                    builder.append(' ');
                }
                builder.append(it.value());
            }
            return builder.toString();
        }

        public boolean equals(Object o) {
            if (!(o instanceof IntStream)) {
                return false;
            }
            IntStream c = (IntStream) o;
            IntIterator it = intIterator();
            IntIterator jt = c.intIterator();
            while (it.isValid() && jt.isValid()) {
                if (it.value() != jt.value()) {
                    return false;
                }
                it.advance();
                jt.advance();
            }
            return !it.isValid() && !jt.isValid();
        }

        public int hashCode() {
            int result = 0;
            for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
                result *= 31;
                result += it.value();
            }
            return result;
        }

    }

    static interface IntSet extends IntCollection {
    }

    static interface IntReversableCollection extends IntCollection {
    }

    static class IntegerUtils {
        public static int gcd(int a, int b) {
            a = Math.abs(a);
            b = Math.abs(b);
            while (b != 0) {
                int temp = a % b;
                a = b;
                b = temp;
            }
            return a;
        }

    }

    static class IntHash {
        private IntHash() {
        }

        public static int hash(int c) {
            return c;
        }

    }
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class BookLibrary{

	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		int days = scanner.nextInt();
		int collections = scanner.nextInt();

		int[] borrowBooks = new int[days];
		for(int i=0; i<days; i++){
			borrowBooks[i] = scanner.nextInt();
		}

		int availableBook = 0;
		int buyNewBook = 0;

		for(int i=0; i<borrowBooks.length; i++){
			if(availableBook > collections){
				int removeBooks = borrowBooks[i] - collections;

				availableBook -= removeBooks;
			}

			if(availableBook < borrowBooks[i]){
				int buyNewBooks = borrowBooks[i] - availableBook;
				buyNewBook += buyNewBooks;

				availableBook += buyNewBooks;
			}
		}

		// System.out.println("availableBook : "+availableBook);
		System.out.println(buyNewBook);
	}

}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class BookLibrary{

	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		int days = scanner.nextInt();
		int collections = scanner.nextInt();

		int[] borrowBooks = new int[days];
		for(int i=0; i<days; i++){
			borrowBooks[i] = scanner.nextInt();
		}

		int availableBook = 0;
		int lastBook = 0;

		int[] collection = new int[collections];
		for(int i=0; i<collection.length; i++){
			collection[i] = 0;
		}

		int buyNewBook = 0;
		int indexAdded = 0;
		int updated = 0;
		for(int i=0; i<borrowBooks.length; i++){
			Boolean wantAdded = false;
			Boolean wantChanged = false;

			int countSame = 0;
			int countZero = 0;
			for(int j=0; j<collection.length; j++){
				if(collection[j] == borrowBooks[i]){
					countSame++;
				}

				if(collection[j] == 0) countZero++;
			}

			if(countSame < collections && countZero != 0){
				wantAdded = true;
			}else{
				wantChanged = true;
			}

			if(wantAdded){
				Boolean isFound = false;

				for(int j=0; j<collection.length; j++){
					if(collection[j] == borrowBooks[i]){
						isFound = true;
					}
				}

				if(!isFound){
					collection[indexAdded] = borrowBooks[i];
					indexAdded += 1;

					buyNewBook++;
				}
			}else if(wantChanged){
				Boolean isFound = false;
				int indexFound;

				for(int j=0; j<collection.length; j++){
					if(collection[j] == borrowBooks[i]){
						isFound = true;
					}
				}

				if(!isFound){
					if(collection.length <= 1){
						collection[collection.length-1] = borrowBooks[i];
						buyNewBook++;
					}else{
						Integer[] newCollection = new Integer[(borrowBooks.length - collection.length -1 -updated)];
						for(int k=0; k<newCollection.length; k++){
							newCollection[k] = borrowBooks[k+collection.length+1+updated];
						}

						int[] findMatchies = new int[collection.length];

						for(int j=0; j<collection.length; j++){
							findMatchies[j] = Arrays.asList(newCollection).indexOf(collection[j]);
						}

						int tempMaxLong = 0;
						int indexLong = 0;
						for(int j=0; j<collection.length; j++){
							if(findMatchies[j] == -1){
								indexLong = j;
								break;
							}

							if(findMatchies[j] > tempMaxLong){
								tempMaxLong = findMatchies[j];
								indexLong = j;
							}
						}

						collection[indexLong] = borrowBooks[i];
						buyNewBook++;

						updated++;
					}
				}
			}

			wantAdded = false;
			wantChanged = false;
		}

		// int[] booksRemove = new int[days];
		// for(int i=0; i<borrowBooks.length; i++){
		// 	if(lastBook != borrowBooks[i]){
		// 		lastBook = borrowBooks[i];

		// 		if(borrowBooks[i] >= collections){
		// 			booksRemove[i] = borrowBooks[i];
		// 		}

		// 		if(i == borrowBooks.length-1){
		// 			for(int j=0; j<booksRemove.length; j++){
		// 				if(lastBook == booksRemove[j]){
		// 					buyNewBook++;
		// 					break;
		// 				}
		// 			}
		// 		}else{
		// 			buyNewBook++;
		// 		}

		// 	// System.out.println("");
		// 	// System.out.println("index : "+i +" : "+borrowBooks[i]);

		// 	// if(availableBook > collections){
		// 	// 	System.out.println("buang");
		// 	// 	int removeBooks = borrowBooks[i] - collections;

		// 	// 	availableBook -= removeBooks;
		// 	// }

		// 	// System.out.println("availableBook : "+availableBook +" borrowBooks : "+borrowBooks[i]);

		// 	// if(availableBook <= borrowBooks[i] || availableBook > borrowBooks[i]){
		// 	// 	System.out.println("tambah");
		// 	// 	int buyNewBooks = borrowBooks[i] - availableBook;
		// 	// 	availableBook += buyNewBooks;

		// 	// 	if(lastBook != borrowBooks[i]){
		// 	// 		lastBook = borrowBooks[i];
		// 	// 		buyNewBook++;
		// 	// 	}
		// 	// }
		// 	// System.out.println("availableBook akhir : "+availableBook);
		// 	}
		// }

		// System.out.println("availableBook : "+availableBook);
		System.out.println(buyNewBook);
	}

}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class BookLibrary{

	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		int days = scanner.nextInt();
		int collections = scanner.nextInt();

		int[] borrowBooks = new int[days];
		for(int i=0; i<days; i++){
			borrowBooks[i] = scanner.nextInt();
		}

		int availableBook = 0;
		int lastBook = 0;

		int[] collection = new int[collections];
		for(int i=0; i<collection.length; i++){
			collection[i] = 0;
		}

		int newBook = 0;
		int buyNewBook = 0;
		int indexAdded = 0;
		for(int i=0; i<borrowBooks.length; i++){
			newBook++;

			Boolean wantAdded = false;
			Boolean wantChanged = false;

			if(newBook <= collections){
				wantAdded = true;
			}else if(newBook > collections){
				wantChanged = true;
			}

			if(wantAdded){
				Boolean isFound = false;

				for(int j=0; j<collection.length; j++){
					if(collection[j] == borrowBooks[i]){
						isFound = true;
					}
				}

				if(!isFound){
					collection[indexAdded] = borrowBooks[i];
					indexAdded += 1;

					buyNewBook++;
				}
			}else if(wantChanged){
				Boolean isFound = false;
				int indexFound;

				for(int j=0; j<collection.length; j++){
					if(collection[j] == borrowBooks[i]){
						isFound = true;
					}
				}

				if(!isFound){
					if(collection.length <= 1){
						collection[collection.length-1] = borrowBooks[i];
						buyNewBook++;
					}else{
						int collectionShorter = 0;

						for(int j=0; j<collection.length; j++){
							for(int k=collection.length; k<borrowBooks.length; k++){
								if(borrowBooks[k] == collection[j]){
									if(collectionShorter == 0) collectionShorter = collection[j];
									break;
								}
							}
						}

						for(int j=0; j<collection.length; j++){
							if(collection[j] != collectionShorter){
								collection[j] = borrowBooks[i];
								buyNewBook++;
								break;
							}
						}
					}
				}
			}

			wantAdded = false;
			wantChanged = false;
		}

		// int[] booksRemove = new int[days];
		// for(int i=0; i<borrowBooks.length; i++){
		// 	if(lastBook != borrowBooks[i]){
		// 		lastBook = borrowBooks[i];

		// 		if(borrowBooks[i] >= collections){
		// 			booksRemove[i] = borrowBooks[i];
		// 		}

		// 		if(i == borrowBooks.length-1){
		// 			for(int j=0; j<booksRemove.length; j++){
		// 				if(lastBook == booksRemove[j]){
		// 					buyNewBook++;
		// 					break;
		// 				}
		// 			}
		// 		}else{
		// 			buyNewBook++;
		// 		}

		// 	// System.out.println("");
		// 	// System.out.println("index : "+i +" : "+borrowBooks[i]);

		// 	// if(availableBook > collections){
		// 	// 	System.out.println("buang");
		// 	// 	int removeBooks = borrowBooks[i] - collections;

		// 	// 	availableBook -= removeBooks;
		// 	// }

		// 	// System.out.println("availableBook : "+availableBook +" borrowBooks : "+borrowBooks[i]);

		// 	// if(availableBook <= borrowBooks[i] || availableBook > borrowBooks[i]){
		// 	// 	System.out.println("tambah");
		// 	// 	int buyNewBooks = borrowBooks[i] - availableBook;
		// 	// 	availableBook += buyNewBooks;

		// 	// 	if(lastBook != borrowBooks[i]){
		// 	// 		lastBook = borrowBooks[i];
		// 	// 		buyNewBook++;
		// 	// 	}
		// 	// }
		// 	// System.out.println("availableBook akhir : "+availableBook);
		// 	}
		// }

		// System.out.println("availableBook : "+availableBook);
		System.out.println(buyNewBook);
	}

}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class BookLibrary{

	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		int days = scanner.nextInt();
		int collections = scanner.nextInt();

		int[] borrowBooks = new int[days];
		for(int i=0; i<days; i++){
			borrowBooks[i] = scanner.nextInt();
		}

		int availableBook = 0;
		int lastBook = 0;

		int[] collection = new int[collections];
		for(int i=0; i<collection.length; i++){
			collection[i] = 0;
		}

		int newBook = 0;
		int buyNewBook = 0;
		int indexAdded = 0;
		for(int i=0; i<borrowBooks.length; i++){
			newBook++;

			Boolean wantAdded = false;
			Boolean wantChanged = false;

			if(newBook <= collections){
				wantAdded = true;
			}else if(newBook > collections){
				wantChanged = true;
			}

			if(wantAdded){
				Boolean isFound = false;

				for(int j=0; j<collection.length; j++){
					if(collection[j] == borrowBooks[i]){
						isFound = true;
					}
				}

				if(!isFound){
					collection[indexAdded] = borrowBooks[i];
					indexAdded += 1;

					buyNewBook++;
				}
			}else if(wantChanged){
				Boolean isFound = false;
				int indexFound;

				for(int j=0; j<collection.length; j++){
					if(collection[j] == borrowBooks[i]){
						isFound = true;
					}
				}

				if(!isFound){
					collection[collection.length-1] = borrowBooks[i];
					buyNewBook++;
				}
			}

			wantAdded = false;
			wantChanged = false;
		}

		// int[] booksRemove = new int[days];
		// for(int i=0; i<borrowBooks.length; i++){
		// 	if(lastBook != borrowBooks[i]){
		// 		lastBook = borrowBooks[i];

		// 		if(borrowBooks[i] >= collections){
		// 			booksRemove[i] = borrowBooks[i];
		// 		}

		// 		if(i == borrowBooks.length-1){
		// 			for(int j=0; j<booksRemove.length; j++){
		// 				if(lastBook == booksRemove[j]){
		// 					buyNewBook++;
		// 					break;
		// 				}
		// 			}
		// 		}else{
		// 			buyNewBook++;
		// 		}

		// 	// System.out.println("");
		// 	// System.out.println("index : "+i +" : "+borrowBooks[i]);

		// 	// if(availableBook > collections){
		// 	// 	System.out.println("buang");
		// 	// 	int removeBooks = borrowBooks[i] - collections;

		// 	// 	availableBook -= removeBooks;
		// 	// }

		// 	// System.out.println("availableBook : "+availableBook +" borrowBooks : "+borrowBooks[i]);

		// 	// if(availableBook <= borrowBooks[i] || availableBook > borrowBooks[i]){
		// 	// 	System.out.println("tambah");
		// 	// 	int buyNewBooks = borrowBooks[i] - availableBook;
		// 	// 	availableBook += buyNewBooks;

		// 	// 	if(lastBook != borrowBooks[i]){
		// 	// 		lastBook = borrowBooks[i];
		// 	// 		buyNewBook++;
		// 	// 	}
		// 	// }
		// 	// System.out.println("availableBook akhir : "+availableBook);
		// 	}
		// }

		// System.out.println("availableBook : "+availableBook);
		System.out.println(buyNewBook);
	}

}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class BookLibrary{

	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		int days = scanner.nextInt();
		int collections = scanner.nextInt();

		int[] borrowBooks = new int[days];
		for(int i=0; i<days; i++){
			borrowBooks[i] = scanner.nextInt();
		}

		int availableBook = 0;
		int buyNewBook = 0;

		for(int i=0; i<borrowBooks.length; i++){
			if(availableBook > collections){
				int removeBooks = borrowBooks[i] - collections;

				availableBook -= removeBooks;
			}

			if(availableBook < borrowBooks[i]){
				int buyNewBooks = borrowBooks[i] - availableBook;
				buyNewBook++;

				availableBook += buyNewBooks;
			}
		}

		// System.out.println("availableBook : "+availableBook);
		System.out.println(buyNewBook);
	}

}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class BookLibrary{

	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		int days = scanner.nextInt();
		int collections = scanner.nextInt();

		int[] borrowBooks = new int[days];
		for(int i=0; i<days; i++){
			borrowBooks[i] = scanner.nextInt();
		}

		int availableBook = 0;
		int buyNewBook = 0;
		int lastBook = 0;

		int[] booksRemove = new int[days];

		for(int i=0; i<borrowBooks.length; i++){
			if(lastBook != borrowBooks[i]){
				lastBook = borrowBooks[i];

				if(borrowBooks[i] >= collections){
					booksRemove[i] = borrowBooks[i];
				}

				if(i == borrowBooks.length-1){
					for(int j=0; j<booksRemove.length; j++){
						if(lastBook == booksRemove[j]){
							buyNewBook++;
							break;
						}
					}
				}else{
					buyNewBook++;
				}
			}

			// System.out.println("");
			// System.out.println("index : "+i +" : "+borrowBooks[i]);

			// if(availableBook > collections){
			// 	System.out.println("buang");
			// 	int removeBooks = borrowBooks[i] - collections;

			// 	availableBook -= removeBooks;
			// }

			// System.out.println("availableBook : "+availableBook +" borrowBooks : "+borrowBooks[i]);

			// if(availableBook <= borrowBooks[i] || availableBook > borrowBooks[i]){
			// 	System.out.println("tambah");
			// 	int buyNewBooks = borrowBooks[i] - availableBook;
			// 	availableBook += buyNewBooks;

			// 	if(lastBook != borrowBooks[i]){
			// 		lastBook = borrowBooks[i];
			// 		buyNewBook++;
			// 	}
			// }
			// System.out.println("availableBook akhir : "+availableBook);
		}

		// System.out.println("availableBook : "+availableBook);
		System.out.println(buyNewBook);
	}

}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;

public class B {

	static StringTokenizer st;
	static BufferedReader br;
	static PrintWriter pw;
	static class Que_Elems implements Comparable<Que_Elems> {
		int id;
		int nextId;
		@Override
		public int compareTo(Que_Elems o) {
			return -(this.nextId-o.nextId);
		}
		public Que_Elems(int id, int nextId) {
			this.id = id;
			this.nextId = nextId;
		}
	}
	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int n = nextInt();
		int k = nextInt();
		int[]a = new int[n];
		int[]next = new int[n];
		int[]last = new int[n+1];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		Arrays.fill(last, n);
		for (int i = n-1; i >= 0; i--) {
			next[i] = last[a[i]];
			last[a[i]] = i;
		}
		int ans = 0;
		PriorityQueue<Que_Elems> q = new PriorityQueue<>();
		Set<Integer> inLibrary = new HashSet<>();
		for (int i = 0; i < n; i++) {
			if (!inLibrary.contains(a[i])) {
				ans++;
				if (q.size() >= k) {
					int whatBook = q.poll().id;
					inLibrary.remove(a[whatBook]);
				}
				q.add(new Que_Elems(i, next[i]));
				inLibrary.add(a[i]);
			}
		}
		System.out.println(ans);
		pw.close();
	}
	private static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	private static long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	private static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
	private static String next() throws IOException {
		while (st==null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}
}