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

public class primes {

public static void main(String []  args){

ArrayList<Integer> numb=new ArrayList<Integer>();
Scanner br1 = new Scanner(System.in);
int n=br1.nextInt();
int steps=br1.nextInt();
//if(n>2)numb.add(2);
if(n>=3)numb.add(3);
for(int j=4;j<=n;j++){
if(chekprime(j)==0){

numb.add(j);
//System.out.println(j);
}

}
int counter =0;
for(int give=0;give<numb.size();give++)
{if("YES".equals(sumup(numb, 2, numb.get(give)))){
 counter++;
// System.out.println(numb.get(give)+"ksjdfskldfgaskldfgasklfgaskldfgaklsfgasdklfgaskldfgaskldfgasdklfg");
 }

}

//System.out.println(counter);
if(counter>=steps)System.out.println("YES");
else System.out.println("NO");

}

public static String sumup(ArrayList<Integer> list,int number,int NUM){

String ret="NO";
    ArrayList<Integer> result=new ArrayList<Integer>();

ArrayList<Integer>[] arList=new ArrayList[number];
for(int i=0;i<number;i++){
arList[i]=new ArrayList<Integer>();
arList[i]=(ArrayList<Integer>)list.clone();
for(int k=0;k<i;k++){
arList[i].add(0,arList[i].remove(arList[i].size()-1));
}

}

    int [] temp=new int[list.size()];

for(int z=0;z<list.size();z++){
    for(int count=0;count<number;count++){

temp[z]+=arList[count].get(z);
//System.out.println(arList[count].get(z));
    }

result.add(temp[z]);

}

if(result.contains(NUM-1))
{    //System.out.println(NUM-1);
ret="YES";
}
return ret;
}

public static int chekprime(int n){
int flag=0;

for(int i=2;i<=Math.sqrt(n)+1;i++)
{
if(n%i==0){
flag=1;
break;
}

}

return flag;

}
}


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {
        //System.setIn(new FileInputStream("1"));
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        int n = nextInt(), k = nextInt();
        int[] primes = new int[n + 1];
        for (int i = 2; i <= n; i++) {
            if (primes[i] == 0) {
                primes[i] = 1;
                for (int j = i * 2; j <= n; j += i)
                    primes[j] = 2;
            }
        }
        ArrayList<Integer> res = new ArrayList<Integer>();
        HashSet<Integer> p = new HashSet<Integer>(), v = new HashSet<Integer>();
        for (int i = 2; i <= n; i++) {
            if (primes[i] == 1) {
                res.add(i);
                p.add(i);
            }
        }
        int c = 0;
        if (res.size() >= 3) {
            for (int i = 2; i < res.size(); i++) {
                int zz = res.get(i - 2) + res.get(i - 1) + 1;
                if (p.contains(zz))
                    v.add(zz);
            }
            c = v.size();
        }
        if (c >= k) {
            out.println("YES");
        } else {
            out.println("NO");
        }
        in.close();
        out.close();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer st;

    static String nextString() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    static int nextInt() throws NumberFormatException, IOException {
        return Integer.parseInt(nextString());
    }

    static double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextString());
    }
}


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

public class Solution {

	Scanner in;
	PrintWriter out;

	boolean isPrime(int x) {
		for (int i = 2; i * i <= x; ++i) {
			if (x % i == 0) {
				return false;
			}
		}
			return true;
	}

	void solve() throws IOException {
		in = new Scanner(System.in);
		//in = new Scanner(new FileReader("input.txt"));
		out = new PrintWriter(System.out);
		int N = in.nextInt();
		int K = in.nextInt();
		List<Integer> primes = new ArrayList<Integer>();
		for (int i = 2; i <= N; ++i) {
			if (isPrime(i)) {
				primes.add(i);
			}
		}
		int c = 0;
		for (int i = 2; i <= N; ++i) {
			if (!isPrime(i)) continue;
			for (int j = 0; j + 1 < primes.size(); ++j) {
				int p1 = primes.get(j);
				int p2 = primes.get(j + 1);
				if (p1 + p2 + 1 == i) {
					++c;
					//out.println(i);
					break;
				}
			}
		}
		if (c >= K) out.println("YES");
		else out.println("NO");
		out.close();
	}

	public static void main(String args[]) throws IOException {
		new Solution().solve();
	}
}


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

public class Noldbach
{
	public Scanner in = new Scanner(System.in);
	public PrintStream out = System.out;

	public boolean[] yes;
	public int n, k;

	public void main()
	{
		n = in.nextInt();
		k = in.nextInt();

		genPrime();
		int i;

		yes = new boolean[n+1];

		int x;
		for(i=0;i+1<prime.length;++i)
		{
			x = prime[i]+prime[i+1]+1;
			if(x <= n && fac[x] == x) yes[x] = true;
		}

		int count = 0;
		for(i=0;i<yes.length;++i) if(yes[i]) ++count;

		out.println((count>=k?"YES":"NO"));
	}//end public void main()

	//Generating Primes
	public int N = 100000+100;
	public int[] fac, rest;
	public int[] prime;

	public void genPrime()
	{
		ArrayList<Integer> ap = new ArrayList<Integer>();
		fac = new int[N];
		rest = new int[N];

		int x,y;
		for(x=0;x<N;++x)
		{
			fac[x] = x;
			rest[x] = 1;
		}

		for(x=2;x<N;++x)
		if(fac[x]==x)
		{
			ap.add(x);
			for(y=x+x;y<N;y+=x)
			if(fac[y]==y)
			{
				fac[y] = x;
				rest[y] = y/x;
			}
		}

		prime = new int[ap.size()];
		for(int i=0;i<prime.length;++i) prime[i] = ap.get(i);
	}

	public static void main(String[] args)
	{
		(new Noldbach()).main();
	}
}


import static java.util.Arrays.*;
import static java.lang.Math.*;
import java.util.*;
import java.io.*;

public class A implements Runnable
{
	public static void main(String [] args) throws IOException
	{
		new Thread(null, new A(), "", 1 << 20).start();
	}

	String file = "input";
	BufferedReader input;
	PrintWriter out;

	public void run()
	{
		try
		{
			//input = new BufferedReader(new FileReader(file + ".in"));
			input = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new BufferedOutputStream(System.out));
			solve();
			input.close();
			out.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
			System.exit(1);
		}
	}

	void solve() throws IOException
	{
		ArrayList<Integer> p = new ArrayList<Integer>();
		StringTokenizer st = tokens();
		int n = nextInt(st), k = nextInt(st);
		for(int i = 2; i <= n; i++)
			if(prime(i)) p.add(i);

		int count = 0;
		for(int x = 2; x <= n; x++)
		{
			if(!prime(x)) continue;
			for(int i = 0; i + 1 < p.size(); i++)
			{
				int p1 = p.get(i);
				int p2 = p.get(i + 1);
				int P = p1 + p2 + 1;
				if(P == x)
				{
					count++;
					break;
				}
				if(P > x) break;
			}
		}
		System.out.println(count >= k ? "YES" : "NO");

	}

	boolean prime(int n)
	{
		for(int i = 2; i * i <= n; i++)
			if(n % i == 0) return false;
		return true;
	}

	StringTokenizer tokens() throws IOException
	{
		return new StringTokenizer(input.readLine());
	}

	String next(StringTokenizer st)
	{
		return st.nextToken();
	}

	int nextInt() throws IOException
	{
		return Integer.parseInt(input.readLine());
	}

	int nextInt(StringTokenizer st)
	{
		return Integer.parseInt(st.nextToken());
	}

	double nextDouble() throws IOException
	{
		return Double.parseDouble(input.readLine());
	}

	double nextDouble(StringTokenizer st)
	{
		return Double.parseDouble(st.nextToken());
	}

	void print(Object... o)
	{
		out.println(deepToString(o));
	}
}


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

public class Noldbach {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		boolean[] sieve=new boolean[1001];
		sieve[2]=false;
		ArrayList<Integer> primes=new ArrayList<Integer>();
		for(int x=2;x<1001;x++)
			if(!sieve[x])
			{
				primes.add(x);
				for(int y=x;y<1001;y+=x)
					sieve[y]=true;
			}
		int sum=0;
		for(int x=2;x<=n;x++)
		{
			if(primes.contains(x))
			{
			int need=x-1;
			for(int y=0;y<primes.size()-1;y++)
			{
				if(primes.get(y)+primes.get(y+1)==need)
				{
					sum++;
					break;
				}
			}
			}
			if(sum==k)break;
		}
		if(sum==k)System.out.println("YES");
		else System.out.println("NO");

	}

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

public class Solution implements Runnable {

	public static void main(String[] args) {
		(new Thread(new Solution())).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	void solve() throws Exception {
		boolean[] r = new boolean[1010];
		Arrays.fill(r, true);
		r[0] = r[1] = false;
		for (int i = 2; i < 1010; i++) {
			if (r[i]) {
				for (int j = i + i; j < 1010; j += i) {
					r[j] = false;
				}
			}
		}
		int[] pr = new int[1010];
		int l = 0;
		for (int i = 2; i < 1010; i++) if (r[i]) pr[l++] = i;
		int n = nextInt();
		int k = nextInt();
		int ans = 0;
		int j = 0;
		for (int i = 2; i <= n; i++) {
			if (r[i]) {
			for (; j < l - 1; j++) {
				if (i == pr[j] + pr[j + 1] + 1) {
					ans++;
					break;
				}
				if (i < pr[j] + pr[j + 1] + 1) break;
			}
			}
		}
		if (ans >= k) out.println("YES"); else out.println("NO");
	}

	public void run() {
		try {
			Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
		} catch (Exception e) {
			e.printStackTrace();
		}
		out.flush();
	}

}


import java.io.*;

import java.awt.geom.Point2D;
import java.text.*;
import java.math.*;
import java.util.*;

public class Main implements Runnable {

    final String filename="";

    public void solve() throws Exception {
        int n = iread(), k = iread();
        boolean[] f = new boolean[10000];
        int prev = -1;
        cycle:for (int i=2; i<=n; i++)
        {
            for (int j=2; j*j<=i; j++)
                if (i%j==0)
                    continue cycle;
            if (prev!=-1)
                f[i+prev+1] = true;
            if (f[i])
                k--;
            prev = i;
        }
        if (k<=0)
            out.write("YES\n");
        else out.write("NO\n");
    }

    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new BufferedWriter(new OutputStreamWriter(System.out));
//          in = new BufferedReader(new FileReader(filename+".in"));
//          out = new BufferedWriter(new FileWriter(filename+".out"));
            solve();
            out.flush();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    public int iread() throws Exception {
        return Integer.parseInt(readword());
    }

    public double dread() throws Exception {
        return Double.parseDouble(readword());
    }

    public long lread() throws Exception {
        return Long.parseLong(readword());
    }

    BufferedReader in;

    BufferedWriter out;

    public String readword() throws IOException {
        StringBuilder b = new StringBuilder();
        int c;
        c = in.read();
        while (c >= 0 && c <= ' ')
            c = in.read();
        if (c < 0)
            return "";
        while (c > ' ') {
            b.append((char) c);
            c = in.read();
        }
        return b.toString();
    }
    public static void main(String[] args) {
        try{
            Locale.setDefault(Locale.US);
        } catch (Exception e)
        {

        }
        new Thread(new Main()).start();
        //new Thread(null, new Main(), "1", 1<<25).start();
    }
}


import java.util.*;

public class Main
{
	static int MAX = 1000;

	static BitSet P = new BitSet(MAX + 1);

	public static boolean Noldbach(int n)
	{
		n--;

		int j;

		for(int i=2; i<=n; i++)
		{
			if(!P.get(i))
			{
				j = i + 1;

				while(P.get(j))
					j++;

				if(i+j == n)
				{
					if(!P.get(i+j+1))
					{
						//System.out.println((n+1)+" = "+i+" + "+(n-i)+" + 1");

						return true;
					}
				}
			}
		}

		return false;
	}

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

		for(int i=2; i*i<=MAX; i++)
		{
		    if(!P.get(i))
		    {
		    	for(int j=i+i; j<=MAX; j+=i)
		    		P.set(j);
		    }
		}

		int n, k, c;

		n = lee.nextInt();
		k = lee.nextInt();

		c = 0;

		for(int i=2; i<=n; i++)
		{
			if(Noldbach(i))
				c++;

			if(c == k)
				break;
		}

		if(c == k)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.InputMismatchException;

/**
 * @author Egor Kulikov (egor@egork.net)
 *         Created on 14.03.2010
 */
public class TaskA implements Runnable {
	private InputReader in;
	private PrintWriter out;

	public static void main(String[] args) {
		new Thread(new TaskA()).start();
//		new Template().run();
	}

	public TaskA() {
//		String id = getClass().getName().toLowerCase();
//		try {
//			System.setIn(new FileInputStream(id + ".in"));
//			System.setOut(new PrintStream(new FileOutputStream(id + ".out")));
//			System.setIn(new FileInputStream("input.txt"));
//			System.setOut(new PrintStream(new FileOutputStream("output.txt")));
//		} catch (FileNotFoundException e) {
//			throw new RuntimeException();
//		}
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);
	}

	public void run() {
//        int numTests = in.readInt();
//        for (int testNumber = 0; testNumber < numTests; testNumber++) {
//        }
		int n = in.readInt();
		int k = in.readInt();
		int last = 2;
		for (int i = 3; i + last < n; i++) {
			boolean good = true;
			for (int j = 2; j * j <= i; j++) {
				if (i % j == 0) {
					good = false;
					break;
				}
			}
			if (good) {
				int p = i + last + 1;
				for (int j = 2; j * j <= p; j++) {
					if (p % j == 0) {
						good = false;
						break;
					}
				}
				if (good)
					k--;
				last = i;
			}
		}
		if (k <= 0)
			out.println("YES");
		else
			out.println("NO");
		out.close();
	}

	private static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1000];
		private int curChar, numChars;

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

		private 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 long readLong() {
			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 String readString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuffer res = new StringBuffer();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private String readLine0() {
			StringBuffer buf = new StringBuffer();
			int c = read();
			while (c != '\n' && c != -1) {
				buf.appendCodePoint(c);
				c = read();
			}
			return buf.toString();
		}

		public String readLine() {
			String s = readLine0();
			while (s.trim().length() == 0)
				s = readLine0();
			return s;
		}

		public String readLine(boolean ignoreEmptyLines) {
			if (ignoreEmptyLines)
				return readLine();
			else
				return readLine0();
		}

		public BigInteger readBigInteger() {
			try {
				return new BigInteger(readString());
			} catch (NumberFormatException e) {
				throw new InputMismatchException();
			}
		}

		public char readCharacter() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			return (char) c;
		}

		public double readDouble() {
			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 < '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 < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}
	}
}


import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists())
				System.setIn(new FileInputStream("input.txt"));
		} catch (SecurityException e) {
		}
		new Thread() {
			public void run() {
				try {
					new Main().run();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}.start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	private void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		boolean[] pr = new boolean[1001];
		for (int i = 2; i <= 1000; i++)
			if (!pr[i]) {
				int l = 2 * i;
				while (l <= 1000) {
					pr[l] = true;
					l += i;
				}
			}
		Set<Integer> set = new HashSet<Integer>();
		for (int i = 2; i < 1000; i++) {
			for (int j = i + 1; j <= 1000; j++) {
				if (!pr[j]) {
					set.add(j + i + 1);
					i = j - 1;
					break;
				}
			}
		}
		int n = nextInt();
		int k = nextInt();
		int res = 0;
		for (int i = 2; i <= n; i++) {
			if (set.contains(i) && !pr[i])
				res++;
		}
		if (res >= k)
			out.println("YES");
		else
			out.println("NO");

		in.close();
		out.close();
	}

	void chk(boolean b) {
		if (b)
			return;
		System.out.println(new Error().getStackTrace()[1]);
		exit(999);
	}
	void deb(String fmt, Object... args) {
		System.out.printf(Locale.US, fmt + "%n", args);
	}
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}


import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    StreamTokenizer in;
    //BufferedReader in;
    PrintWriter out;
    public static void main(String[] args) throws IOException {
        new Main().run();
    }
    int ni() throws IOException {
        in.nextToken(); return (int)in.nval;
    }
    void run() throws IOException {
        //in = new StreamTokenizer(new BufferedReader(new FileReader("input.txt")));
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(new OutputStreamWriter(System.out));
        //out = new PrintWriter(new FileWriter("output.txt"));
        int cprime = 0;
        int[] prime = new int[1000];
        for(int i = 2; i < 1001; i++) {
            boolean f = false;
            for(int j = 2; j*j <= i; j++)
                if(i % j == 0) {
                    f = true; break;
                }
            if(!f) prime[cprime++] = i;
        }
        int n = ni(), k = ni();
        int last = 0;
        int count = 0;
        for(int i = 0; i < cprime && prime[i] <= n; i++) {
            for(int j = 0; j < cprime - 1; j++)
                if(prime[j] + prime[j + 1] + 1 == prime[i]) {
                    count++; break;
                }
                else if(prime[j] + prime[j + 1] + 1 > prime[i]) break;
        }
        if(count >= k) out.print("YES");
        else out.print("NO");
        out.flush();
    }
}


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

public class A {

	public static void main(String[] args) {
		new A().run();
	}

	private void run() {
		Scanner sc =new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		sc.close();
		boolean[] isp = new boolean[n + 1];
		Arrays.fill(isp, true);
		isp[1] = false;
		int[] primes = new int[n];
		int pc = 0;
		for (int i = 2; i <= n; i++) {
			if (isp[i]) {
				primes[pc++] = i;
				for (int j = i * i; j <= n; j+= i) {
					isp[j] = false;
				}
			}
		}
		int res = 0;
		for (int i = 0; i < pc; i++) {
			for (int j = 1; j < i; j++)
					if (primes[i] == primes[j] + primes[j - 1] + 1)
						res++;
		}
		System.out.println(res >= k ? "YES" : "NO");
	}

}


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

/**
 * Created by HREN_VAM.
 */

public class A implements Runnable{

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st;
    public static final String filename = "";

    public void solve() throws IOException{

        int n = nextInt();

        int[] a = new int[n + 1];
        ArrayList<Integer> pr = new ArrayList<Integer>();

        for(int i = 2;i < n + 1;i ++){
            if(a[i] != 0)continue;
            pr.add(i);
            for(int j = 2 * i;j < n + 1;j += i){
                a[j] = 1;
            }
        }

        int k = nextInt();
        for(int i = 2;i < n + 1;i ++){
            if(a[i] != 0)continue;
            for(int j = 1;j < pr.size();j ++){
                if(i == pr.get(j) + pr.get(j - 1) + 1){
                    k --;
                    break;
                }
            }
        }
        if(k > 0){
            out.println("NO");
            return;
        }
        out.println("YES");
    }

    public void run(){
        try{
            Locale.setDefault(Locale.US);
            in = new BufferedReader(new InputStreamReader(System.in));
            //in = new BufferedReader(new FileReader(filename + ".in"));
            out = new PrintWriter(System.out);
            //out = new PrintWriter(new FileWriter(filename + ".out"));
            st = new StringTokenizer("");
            solve();
            out.close();
        } catch(IOException e){
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args){
        new Thread(new A()).start();
    }

    public String nextToken() throws IOException{
        while(!st.hasMoreTokens()){
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    public int nextInt() throws IOException{
        return Integer.parseInt(nextToken());
    }

    public double nextDouble() throws IOException{
        return Double.parseDouble(nextToken());
    }
}


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

public class Main {
	static Scanner in;
	static PrintWriter out;
//	static final String PROBLEM = "";

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

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

		boolean[] p = new boolean[n + 5];
		int[] pp = new int[n + 5];
		int ind = 0;
		Arrays.fill(p, true);
		p[0] = false;
		p[1] = false;
		for (int i = 2; i < n + 5; i++)
			if (p[i]) {
				pp[ind++] = i;
				for (int j = 2*i; j < n + 5; j += i) p[j] = false;
			}
//	    for (int i = 0; i < 30; i++) if (p[i]) out.println(i);

		boolean[] b = new boolean[n + 1];
		for (int i = 0; i < ind - 1; i++)
			if (pp[i] + pp[i + 1] + 1 <= n && p[pp[i] + pp[i + 1] + 1]) b[pp[i] + pp[i + 1] + 1] = true;

		int kol = 0;
		for (int i = 2; i <= n; i++)
			if (b[i]) kol++;

		if (kol >= k) out.println("YES");
		else out.println("NO");

		out.close();
	}
}


import java.io.*;
import java.util.*;
public class Answer17A{
    public static void main(String[] args){
	try{
	    BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
	    String[] tmp=reader.readLine().split(" ");
	    int n=Integer.parseInt(tmp[0]);
	    int k=Integer.parseInt(tmp[1]);
	    boolean[] m=getPrime(n);
	    ArrayList<Integer> prime=new ArrayList<Integer>();
	    for(int i=0;i<m.length;i++){
		if(m[i])prime.add(i);
	    }
	    int sum=0;
	    for(int i=2;i<=n;i++){
		if(m[i]){
		    for(int j=0;j<prime.size()-1;j++){
			if(i==prime.get(j)+prime.get(j+1)+1){
			    sum++;
			    break;
			}
		    }
		}
	    }
	    if(sum>=k){
		System.out.println("YES");
	    }else{
		System.out.println("NO");
	    }
	}catch(IOException e){
	    e.printStackTrace();
	}
    }
    public static boolean[] getPrime(int N){
	boolean[] memo=new boolean[N+1];
	Arrays.fill(memo,true);
	memo[0]=false;
	memo[1]=false;
	for(int i=2;i*i<=N;i++){
	    if(memo[i]){
		for(int j=i*i;j<=N;j+=i){
		    memo[j]=false;
		}
	    }
	}
	return memo;
    }

}


import java.util.LinkedList;
import java.util.Locale;
import java.util.Scanner;

public class A{

    void exe(){
        LinkedList<Integer> list=new LinkedList<Integer>();
        for(int i=2;i<=1000;i++)
            if(isPrime(i))
                list.add(i);
        Object[] primes=list.toArray();

        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int cnt=0;
        for(int c=2;c<=n;c++){
            if(!isPrime(c))
                continue;
            for(int i=0;i<primes.length-1;i++){
                int p1=(Integer)primes[i];
                int p2=(Integer)primes[i+1];
                if(c==1+p1+p2){
//                  System.out.println("c="+c+", i="+p1+", j="+p2);
                    cnt++;
                }
            }
        }
        if(cnt>=k){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }

    boolean isPrime(int n){
        if(n<=1)return false;
        if(n==2)return true;
        if(n%2==0)return false;
        int m=(int)Math.sqrt(n)+1;
        for(int i=3;i<=m;i+=2)
            if(n%i==0)
                return false;
        return true;
    }

    public static void main(String[] args){
        Locale.setDefault(Locale.US);
        new A().exe();
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * Problem solution template.
 * @author Andrew Porokhin, andrew.porokhin@gmail.com
 */
public class Problem17A implements Runnable {
    void solve() throws NumberFormatException, IOException {

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

        ArrayList<Integer> primes = new ArrayList<Integer>(n + 1);
        boolean[] simplePrime = new boolean[n + 1];
        Arrays.fill(simplePrime, 0, simplePrime.length, true);
        simplePrime[0] = simplePrime[1] = false;

        for (int i = 2; i <= n; i++) {
            if (simplePrime[i]) {
                for (int j = i + i; j <= n; j += i) {
                    simplePrime[j] = false;
                }

                primes.add(i);
            }
        }

        int actualK = 0;
        for (int i = 1; i < primes.size(); i++) {
            int val = primes.get(i - 1) + primes.get(i) + 1;
            if (val <= n) {
                if (simplePrime[val]) {
                    // System.out.printf("%d + %d + 1 = %d%n", primes.get(i - 1), primes.get(i), val);
                    actualK++;
                }
            } else {
                break;
            }
        }
        // System.out.printf("req: %d actual: %d%n", k, actualK);
        System.out.println((k <= actualK ? "YES" : "NO"));
    }

    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) {
        new Problem17A().run();
    }

    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            out.flush();
            out.close();
        }
    }

    String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws NumberFormatException, IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws NumberFormatException, IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }
}


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

public class Solution {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st;

    int n, k;

    boolean[] prime;
    int[] primes;

    void sieve() {
        prime = new boolean[n + 1];
        Arrays.fill(prime, true);
        prime[0] = prime[1] = false;
        int cnt = 0;
        for (int i = 2; i <= n; ++i)
            if (prime[i]) {
                ++cnt;
                for (int j = i + i; j <= n; j += i)
                    prime[j] = false;
            }
        primes = new int[cnt];
        cnt = 0;
        for (int i = 0; i <= n; ++i)
            if (prime[i])
                primes[cnt++] = i;
    }

    void solve() throws IOException {
        n = ni();
        k = ni();
        sieve();
        int cnt = 0;
        for (int i = 2; i <= n; ++i) {
            if (!prime[i])
                continue;
            boolean ok = false;
            for (int j = 0; j < primes.length - 1; ++j)
                if (primes[j] + primes[j + 1] + 1 == i) {
                    ok = true;
                    break;
                }
            if (ok)
                ++cnt;
        }
        if (cnt >= k)
            out.println("YES");

        else
            out.println("NO");
    }

    public Solution() throws IOException {
        Locale.setDefault(Locale.US);
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

    String ns() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    int ni() throws IOException {
        return Integer.valueOf(ns());
    }

    long nl() throws IOException {
        return Long.valueOf(ns());
    }

    double nd() throws IOException {
        return Double.valueOf(ns());
    }

    public static void main(String[] args) throws IOException {
        new Solution();
    }
}


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

public class ProblemaNoldbaha implements Runnable{
	public static void main(String[] args) throws IOException {
		new Thread(new ProblemaNoldbaha()).start();
	}

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

	public String nextToken() throws IOException{
		while (in == null || !in.hasMoreTokens()){
			in = new StringTokenizer(br.readLine());
		}

		return in.nextToken();
	}

	public int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException{
		return Double.parseDouble(nextToken());
	}

	public void solve() throws IOException{
		int n = nextInt();
		int k = nextInt();

		int[] prime = new int[1000];

		int l = 0;

		for (int i = 2; i <= n; i++) {
			boolean f = false;
			for (int j = 2; j < i; j++) {
				if (i % j == 0){
					f = true;
					break;
				}
			}

			if (!f){
				prime[l] = i;
				l++;
			}
		}

		int count = 0;
		for (int i = 2; i < l; i++) {
			boolean f = false;
			for (int j = 0; j < l - 1; j++) {
				if (prime[j] + prime[j + 1] + 1 == prime[i]){
					f = true;
					break;
				}
			}

			if (f) count++;
		}

		if (count >= k){
			out.println("YES");
		}
		else{
			out.println("NO");
		}
	}

	public void run(){
		try{
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			solve();

			out.close();
		}
		catch(IOException e){
			e.printStackTrace();
			System.exit(1);
		}
	}
}


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

public class A {
    private static Scanner sc = new Scanner(new InputStreamReader(System.in));
    public static void main (String[] args) throws IOException {
        BitSet b = new BitSet(1001);
        BitSet p = primes(1001);
        for (int i = 0; i < ps.length - 1; i++) {
            b.set(ps[i] + ps[i+1] + 1);
        }
        int n = sc.nextInt(), k = sc.nextInt();
        for (int x = 0; x <= n; x++) {
            if (b.get(x) && p.get(x)) k--;
        }
        System.out.println(k > 0 ? "NO" : "YES");
    }

    private static BitSet primes (int n) {
        BitSet b = new BitSet(n+1);
        b.set(2, n);
        for (int p = 2; p <= n; p++) {
            if (b.get(p)) {
                for (int x = p * 2; x <= n; x += p) {
                    b.clear(x);
                }
            }
        }
        return b;
    }
        private static int [] ps = new int[] {2,
                3,
                5,
                7,
                11,
                13,
                17,
                19,
                23,
                29,
                31,
                37,
                41,
                43,
                47,
                53,
                59,
                61,
                67,
                71,
                73,
                79,
                83,
                89,
                97,
                101,
                103,
                107,
                109,
                113,
                127,
                131,
                137,
                139,
                149,
                151,
                157,
                163,
                167,
                173,
                179,
                181,
                191,
                193,
                197,
                199,
                211,
                223,
                227,
                229,
                233,
                239,
                241,
                251,
                257,
                263,
                269,
                271,
                277,
                281,
                283,
                293,
                307,
                311,
                313,
                317,
                331,
                337,
                347,
                349,
                353,
                359,
                367,
                373,
                379,
                383,
                389,
                397,
                401,
                409,
                419,
                421,
                431,
                433,
                439,
                443,
                449,
                457,
                461,
                463,
                467,
                479,
                487,
                491,
                499};
}


import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.fill;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.sort;

public class Main {
	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists()) {
				System.setIn(new FileInputStream("input.txt"));
			}
		} catch (SecurityException e) {
		}

		new Main().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	boolean[] erat = new boolean [1000 + 1];
	int[] primes = new int [1000 + 1];
	int pNum = 0;

	void run() throws IOException {

		for (int i = 2; i <= 1000; i++) {
			if (!erat[i]) {
				primes[pNum++] = i;
				for (int j = i * i; j <= 1000; j += i)
					erat[j] = true;
			}
		}

		int[] cnt = new int [1000 + 1];
		cnt[2] = 0;

		for (int i = 3; i <= 1000; i++) {
			cnt[i] = cnt[i - 1];
			if (!erat[i]) {
				int r = i - 1;
				for (int j = 1; j < pNum; j++) {
					if (r == primes[j - 1] + primes[j]) {
						cnt[i]++;
						break;
					}
				}
			}
		}

		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

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

		out.println(k <= cnt[n] ? "YES" : "NO");

		out.close();
	}

	String nextToken() throws IOException {
		while (!st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}

		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}

	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}


import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Naldbah implements Runnable {

    boolean isLocalMode = false;

    public static void main(String[] args) {
        new Naldbah().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(getReader());
            tokenizer = null;
            writer = new PrintWriter(System.out);
            //do job
            doJob();

            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    private void doJob() throws IOException {
        int n = nextInt();
        int k = nextInt();
        boolean[] primes = sieve(n + 1);

        for(int i=n;i>=2;i--){
            if(primes[i]){
                int solve = i-1;
                int sn=getNextD(primes,solve);
                int en = getNextD(primes,n);
                while(en!=-1&&sn+en>=solve){
                    if((sn+en)==solve)k--;
                    sn=en;
                    en=getNextD(primes,en);
                }
            }
        }
        writer.write(k<=0?"YES":"NO");
    }

    private int getNextD(boolean[] primes, int i) {
        for(int p = i-1;p>=2;p--){
            if(primes[p])return p;
        }
        return -1;
    }

    public boolean[] sieve(int n)
    {
       boolean[] prime=new boolean[n+1];
       Arrays.fill(prime,true);
       prime[0]=false;
       prime[1]=false;
       int m= (int) Math.sqrt(n);

       for (int i=2; i<=m; i++)
          if (prime[i])
             for (int k=i*i; k<=n; k+=i)
                prime[k]=false;

       return prime;
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    public Reader getReader() throws FileNotFoundException {
        if (isLocalMode) {
            return new FileReader("input.txt");
        } else {
            return new InputStreamReader(System.in);
        }
    }
}


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

public class A implements Runnable {
	public static void main(String[] args) {
		new A().run();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		boolean eof;
		String buf;

		public FastScanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
			nextToken();
		}

		public FastScanner(InputStream stream) {
			br = new BufferedReader(new InputStreamReader(stream));
			nextToken();
		}

		String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					eof = true;
					break;
				}
			}
			String ret = buf;
			buf = eof ? "-1" : st.nextToken();
			return ret;
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}

		void close() {
			try {
				br.close();
			} catch (Exception e) {

			}
		}

		boolean isEOF() {
			return eof;
		}
	}

	FastScanner sc;
	PrintWriter out;

	public void run() {
		Locale.setDefault(Locale.US);
		try {
			sc = new FastScanner(System.in);
			out = new PrintWriter(System.out);
			solve();
			sc.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() {
		return sc.nextInt();
	}

	String nextToken() {
		return sc.nextToken();
	}

	long nextLong() {
		return sc.nextLong();
	}

	double nextDouble() {
		return sc.nextDouble();
	}

	boolean isPrime(int x) {
		for (int i = 2; i * i <= x; i++) {
			if (x % i == 0) {
				return false;
			}
		}
		return true;
	}

	void solve() {
		int n = nextInt();
		int k = nextInt();
		ArrayList<Integer> primes = new ArrayList<Integer>();
		for (int i = 2; i <= n; i++) {
			if (isPrime(i)) {
				primes.add(i);
			}
		}
		int ans = 0;
		for (int i = 0; i < primes.size(); i++) {
			for (int j = 0; j < i - 1; j++) {
				if (primes.get(j) + primes.get(j + 1) + 1 == primes.get(i)
						.intValue()) {
					ans++;
					break;
				}
			}
		}
		if (ans >= k) {
			out.println("YES");

		} else {
			out.println("NO");
		}
	}
}


import java.util.*;
import java.io.*;
public class Main
{
	public static void main(String args[]) throws IOException
	{
		Scanner sc = new Scanner(System.in);
                int n = sc.nextInt(), k = sc.nextInt(), kol = 0, prev;
                boolean ok;
                ArrayList<Integer> al = new ArrayList<Integer>();
                al.add(2);
                prev = 2;
                for(int i=3;i<=n;i+=2)
                {
                	ok = true;
                	for(Integer x: al)
                	if (i%x == 0)
                	{
                		ok = false;
                		break;
                	}
                	if (ok)
                	{
                		for(Integer x: al)
                		if (ok)
                		{
                			prev = x;
                			ok = false;
                		} else
                		{
	                		if (x + prev + 1 == i)
	                		{
	                			kol++;
	                			break;
	                		}
	                		if (x + prev + 1 > i) break;
	                		prev = x;
                		}
                		al.add(i);
                	}
                }
                if (kol >= k) System.out.print("YES"); else System.out.print("NO");
	}
}


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class A {
	public static void main(String[] args) throws Exception {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt()-1;
		PrimeGen p = new PrimeGen(n);
		List<Integer> prims = new ArrayList<Integer>();
		for(int i = 2; i <= n; i++){
			if(p.isPrime(i)>0){
				prims.add(i);
			}
		}
		int sum = 0;
		for(int i = 0; i < prims.size() - 1; i++){
			int c = prims.get(i) + prims.get(i+1) + 1;
			if(c <= n && p.isPrime(c)>0){
				sum ++;
			}
		}
		System.out.println(sum>=k?"YES":"NO");
	}

	static int sum(List<Integer> is) {
		int c = 0;
		for (int i : is)
			c += i;
		return c;
	}

	static class PrimeGen {
		public PrimeGen(int m) {
			m = (int) Math.sqrt(m);
			double max = 0;
			int r = 1;
			for (int i = 0; i < 4;) {
				max += r * m / Math.pow(Math.log1p(m), ++i);
				r *= i;
			}
			p = new int[(int) max];
			for (int i = 0, e = 2; i < p.length; i++) {
				for (; isPrime(e) < 1; e++)
					;
				p[i] = e++;
			}
			this.m = p[p.length - 1];
			this.m = this.m * this.m;
		}

		int isPrime(int n) {
			for (int e : p)
				if (e < 1)
					break;
				else if (n != e && n % e < 1)
					return 0;
			return 1;
		}

		int max() {
			return m;
		}

		int[] p;
		int m;
	}
}


//package codeforces.br17;

import java.io.*;
import java.text.DecimalFormat;

public class ProblemA {
    public void solve() {
        boolean oj = true;

        try {
            Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("A.in");
            Writer writer = oj ? new OutputStreamWriter(System.out) : new FileWriter("A.out");
            BufferedReader br = new BufferedReader(reader);
            PrintWriter out = new PrintWriter(writer);

            MyTokenizer tok = new MyTokenizer(br.readLine());

            int n = (int)tok.getNum();
            int k = (int)tok.getNum();

            boolean[] isPrime = new boolean[n + 1];
            for(int i=1;i<=n;i++)
                isPrime[i] = true;
            isPrime[1] = false;
            isPrime[2] = true;
            for(int i=2;i*i<=n;i++)
                for(int j=2*i;j<=n;j+=i)
                    isPrime[j] = false;
            int[] primes = new int[n];
            int cur = 0;
            for(int i=2;i<=n;i++)
                if (isPrime[i]) {
                    primes[cur] = i;
                    cur++;
                }
            int count = 0;
            for(int i=0;i<cur-1;i++) {
                if (primes[i] + primes[i+1] + 1 <= n && isPrime[primes[i] + primes[i+1] + 1])
                    count++;
            }
            if (count >= k)
                out.printf("YES");
            else
                out.printf("NO");

            br.close();
            out.close();
            reader.close();
            writer.close();
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }
        finally {
        }
    }

    public static void main(String[] args) {
        ProblemA f = new ProblemA();
        f.solve();
    }

    private class MyTokenizer {
        private String s;
        private int cur;

        public MyTokenizer(String s) {
            this.s = s;
            cur = 0;
        }

        public void skip() {
            while (cur < s.length() && (s.charAt(cur) == ' ' || s.charAt(cur) == '\n')) {
                cur++;
            }
        }

        public double getNum() {
            skip();
            String snum = "";
            while (cur < s.length() && (s.charAt(cur) >= '0' && s.charAt(cur) <= '9' || s.charAt(cur) == '.')) {
                snum += s.charAt(cur);
                cur++;
            }
            return Double.valueOf(snum);
        }

        public String getString() {
            skip();
            String s2 = "";
            while (cur < s.length() && (s.charAt(cur) >= 'a' && s.charAt(cur) <= 'z')) {
                s2 += s.charAt(cur);
                cur++;
            }
            return s2;
        }

        public char getCurrentChar() throws Exception {
            if (cur < s.length())
                return s.charAt(cur);
            else
                throw new Exception("Current character out of string length");
        }

        public void moveNextChar() {
            if (cur < s.length())
                cur++;
        }

        public boolean isFinished() {
            return cur >= s.length();
        }
    }
}


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

public class Main implements Runnable {
	BufferedReader in;
	StringTokenizer st = new StringTokenizer("");

	public static void main(String [] args) throws Exception {
		new Thread(new Main()).start();
	}

	 void printExit(String s) {
		System.out.println(s);
		System.exit(0);
	}

	public void run() {
		try {
			Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader(System.in));
			int n = nextInt();
			int k = nextInt();
			int max = 5000;
			ArrayList <Integer> primes = new ArrayList <Integer> ();
			boolean [] p = new boolean [max];
			Arrays.fill(p, true);
			for (int i = 2; i < max; i++) {
				if (p[i]) {
					primes.add(i);
					for (int j = i * i; j < max; j += i)
						p[j] = false;
				}

			}

			HashSet <Integer> good = new HashSet <Integer> ();
			for (int i = 0; i < primes.size() - 1; i++) {
				good.add(primes.get(i) + primes.get(i + 1) + 1);
			}

			int have = 0, pos = 0;
			while (true) {
				int i = primes.get(pos);
				if (i > n) break;
				if (good.contains(i)) have++;
				pos++;
			}
			System.out.println(have >= k ? "YES" : "NO");
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}

	 boolean seekForToken() {
 		try {
			while (!st.hasMoreTokens()) {
				String s = in.readLine();
				if (s == null) {
				 	return false;
				}
			 	st = new StringTokenizer(s);
			}
			return true;
		}
		catch (IOException e) {
		 	e.printStackTrace();
		 	return false;
		}
 	}

 	 int nextInt() {
		return Integer.parseInt(nextToken());
 	}

 	 long nextLong() {
		return Long.parseLong(nextToken());
 	}

 	 double nextDouble() {
		return Double.parseDouble(nextToken());
 	}

 	 BigInteger nextBigInteger() {
 	 	return new BigInteger(nextToken());
 	}

 	 String nextToken() {
 	 	seekForToken();
 	 	return st.nextToken();
 	}

}


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

public class Noldbach {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		boolean[] sieve=new boolean[1001];
		sieve[2]=false;
		ArrayList<Integer> primes=new ArrayList<Integer>();
		for(int x=2;x<1001;x++)
			if(!sieve[x])
			{
				primes.add(x);
				for(int y=x;y<1001;y+=x)
					sieve[y]=true;
			}
		int sum=0;
		for(int x=2;x<=n;x++)
		{
			if(primes.contains(x))
			{
			int need=x-1;
			for(int y=0;y<primes.size()-1;y++)
			{
				if(primes.get(y)+primes.get(y+1)==need)
				{
					sum++;
					break;
				}
			}
			}
			if(sum==k)break;
		}
		if(sum==k)System.out.println("YES");
		else System.out.println("NO");

	}

}


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

public class Main  implements Runnable {
//public static final String FileName = "test";
StreamTokenizer ST;
PrintWriter out;
BufferedReader br;
Scanner in;
static final int inf = 1000000000;

int nextInt() throws IOException{
    ST.nextToken();
    return (int)ST.nval;
}
long nextLong() throws IOException{
    ST.nextToken();
    return (long)ST.nval;
}
String next() throws IOException{
    ST.nextToken();
    return ST.sval;
}
double nextD() throws IOException{
    ST.nextToken();
    return ST.nval;
}
public static void main(String[] args) throws IOException {
   new Thread(new Main()).start();
//  new Main().run();
}

public void run()  {
    try {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        //br = new BufferedReader(new FileReader(new File(FileName+".in")));
        //out = new PrintWriter(new BufferedWriter(new FileWriter(FileName+".out")));
        in = new Scanner(br);
        ST = new StreamTokenizer(br);
        solve();
        out.close();
        //in.close();
        br.close();
    }
    catch (IOException e) {
        e.printStackTrace();
        throw new IllegalStateException(e);
    }
}

public void solve() throws IOException {
    int n = nextInt();
    int K = nextInt();
    boolean[] f = new boolean[n+1];
    Arrays.fill(f, true);
    Vector<Integer> P = new Vector<Integer>();
    for (int i=2; i<=n; i++)
        if (f[i]) {
            for (int j=2*i; j<=n; j+=i)
                f[j] = false;
            P.add(i);
        }
    for (int i=0; i<P.size()-1; i++) {
        int x = P.elementAt(i)+P.elementAt(i+1)+1;
        if (x<=n && f[x]) K--;
    }
    if (K<=0) out.println("YES"); else out.println("NO");
    //for (int x:P) out.print(x+" ");

}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class A {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = new String(in.readLine());
        String[] t=s.split(" ");
        int n = Integer.parseInt(t[0]);
        int k = Integer.parseInt(t[1]);
        boolean[] prime=new boolean[n+1];
        for (int i=2;i<Math.sqrt(n);i++) {
        	for (int j=i+i;j<=n;j=j+i) {
        		prime[j]=true;
        	}
        }
        int size=0;
        for (int i=2;i<=n;i++) {
        	if (!prime[i]) {
        		size++;
        	}
        }
        int[] pn=new int[size];
        int index=0;
        for (int i=2;i<=n;i++) {
        	if (!prime[i]) {
        		pn[index]=i;
        		index++;
        	}
        }
        for (int i=2;i<size;i++) {
        	for (int j=0;j<i;j++) {
        		if (pn[i]==pn[j]+pn[j+1]+1) {
//       			System.out.println(pn[i]+"="+pn[j]+"+"+pn[j+1]+"+1");
        			k--;
        		}
        	}
        }
        if (k<=0) {
        	System.out.println("YES");
        } else {
        	System.out.println("NO");
        }
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.HashSet;

public class E17 {

	static StreamTokenizer in;
	static PrintWriter out;

	static int nextInt() throws IOException {
		in.nextToken();
		return (int)in.nval;
	}

	static String nextString() throws IOException {
		in.nextToken();
		return in.sval;
	}

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

		int n = nextInt(), k = nextInt();
		int MAX = n, nprimes = 0;
		int[] primes = new int[MAX];
		boolean[] isPrime = new boolean[MAX+1];
		Arrays.fill(isPrime, true);
		isPrime[0] = false;
		isPrime[1] = false;
		for (int i = 2; i <= MAX; i++) if (isPrime[i]) {
			primes[nprimes++] = i;
			for (int j = i + i; j <= MAX; j += i) isPrime[j] = false;
		}
		primes[nprimes] = Integer.MAX_VALUE;

		HashSet<Integer> h = new HashSet<Integer>();
		for (int i = 1; i < nprimes; i++) {
			int x = primes[i-1] + primes[i] + 1;
			if (x > n) break;
			if (isPrime[x]) h.add(x);
		}

		out.println(h.size() >= k ? "YES" : "NO");

		out.flush();
	}
}


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

public class Solution {

	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;

	void solve() throws IOException {
		int n = nextInt();
		int k = nextInt();
		ArrayList<Integer> ps = new ArrayList<Integer>();
		boolean[] prime = new boolean[n + 1];
		Arrays.fill(prime, true);
		prime[0] = prime[1] = false;
		for (int i = 2; i <= n; ++i) {
			if (prime[i]) {
				ps.add(i);
				for (int j = 2 * i; j <= n; j += i) {
					prime[j] = false;
				}
			}
		}
		for (int i = 0; i < ps.size() - 1; ++i) {
			int t = ps.get(i) + ps.get(i + 1) + 1;
			if (t <= n && prime[t]) {
				--k;
			}
		}
//		System.out.println(k);
		out.println(k <= 0 ? "YES" : "NO");
	}

	Solution() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		eat("");

		solve();

		in.close();
		out.close();
	}

	private void eat(String str) {
		st = new StringTokenizer(str);
	}

	String next() throws IOException {
		while (!st.hasMoreTokens()) {
			String line = in.readLine();
			if (line == null) {
				return null;
			}
			eat(line);
		}
		return st.nextToken();
	}

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

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

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

	public static void main(String[] args) throws IOException {
		new Solution();
	}
}


import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;
public class Main
{
    Scanner cin;
    int []prime;
    int top;
    void work()
    {
        cin=new Scanner(System.in);
        int n=cin.nextInt();
        int k=cin.nextInt();
        top=0;
        prime=new int[2000];
        for(int i=2;i<=n;i++)
        {
        	if(isprime(i))
        		prime[top++]=i;
        }
        int cnt=0;
        for(int i=0;i<top;i++)
        {
        	if(cando(prime[i]))
        		cnt++;
        }
        if(cnt>=k) System.out.println("YES");
        else System.out.println("NO");
    }
    boolean cando(int n)
    {
    	for(int i=0;i<top-1;i++)
    	{
    		if(prime[i]+prime[i+1]+1==n) return true;
    	}
    	return false;
    }
    boolean isprime(int n)
    {
    	for(int i=2;i*i<=n;i++)
    		if(n%i==0)return false;
    	return true;
    }
  public static void main(String args[]) throws Exception
  {

   new Main().work();
  }

}


import java.util.*;

public class Beta17PA {

	boolean[] isPrime = new boolean[1001];
	int[] prime = new int[200];

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Beta17PA().solve();
	}

	public void solve() {
		Scanner scan = new Scanner(System.in);
		int n, k;
		n = scan.nextInt();
		k = scan.nextInt();
		init();
		int m = 0;
		for(int i=2; i<=n; i++) {
			if(check(i)) m ++;
		}
		if(m>=k) System.out.println("YES");
		else System.out.println("NO");
	}

	private boolean check(int n) {
		if(n<6||!isPrime[n]) return false;
		int d = n-1;
		for(int i=0; i<199&&prime[i]+prime[i+1]<=d; i++) {
			if(prime[i]+prime[i+1]==d) return true;
		}
		return false;
	}

	private void init() {
		Arrays.fill(isPrime, true);
		isPrime[0] = isPrime[1] = false;
		for(int i=2; i<1001; i++) {
			if(!isPrime[i]) continue;
			for(int j=i+i; j<1001; j+=i) {
				isPrime[j] = false;
			}
		}
		int count = 0;
		for(int i=2; i<1001; i++) {
			if(isPrime[i]) prime[count++] = i;
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class A {
    BufferedReader in;
    StringTokenizer st;
    PrintWriter out;

    void solve() throws IOException {
        int n = nextInt();
        int k = nextInt();
        boolean[] sieve = new boolean[n + 1];
        List<Integer> primes = new ArrayList<Integer>();
        for (int i = 2; i <= n; ++i) {
            if (!sieve[i]) {
                primes.add(i);
                for (int j = 2 * i; j <= n; j += i) {
                    sieve[j] = true;
                }
            }
        }
        int count = 0;
        for (int i = 0; i + 1 < primes.size(); ++i) {
            int v = primes.get(i) + primes.get(i + 1) + 1;
            if (v <= n && !sieve[v]) {
                ++count;
            }
        }
//        System.err.println(count);
        out.println(count >= k ? "YES" : "NO");
    }

    public void run() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        eat("");
        solve();
        out.close();
        in.close();
    }

    void eat(String s) {
        st = new StringTokenizer(s);
    }

    String next() throws IOException {
        while (!st.hasMoreTokens()) {
            String line = in.readLine();
            if (line == null) {
                return null;
            }
            eat(line);
        }
        return st.nextToken();
    }

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

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

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

    public static void main(String[] args) throws IOException {
        new A().run();
    }
}


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

public class Solution implements Runnable{
    private static BufferedReader br = null;
    private static PrintWriter out = null;
    private static StringTokenizer stk = null;

    public static void main(String[] args) {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        (new Thread(new Solution())).start();
    }

    private void loadLine() {
        try {
            stk = new StringTokenizer(br.readLine());
        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }

    private String nextLine() {
        try {
            return br.readLine();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    private Integer nextInt() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Integer.parseInt(stk.nextToken());
    }

    private Long nextLong() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Long.parseLong(stk.nextToken());
    }

    private String nextWord() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return (stk.nextToken());
    }

    private Double nextDouble() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Double.parseDouble(stk.nextToken());
    }

    public void run() {
        int n = nextInt();
        int k = nextInt();

        boolean[] isP = new boolean[2*n];
        Arrays.fill(isP, true);
        isP[0] = isP[1] = false;

        for (int i = 0; i <= n; ++i) {
            if (isP[i]) {
                for (int j = i+i; j <= n; j+=i) {
                    isP[j] = false;
                }
            }
        }

        ArrayList<Integer> p = new ArrayList<Integer>();
        for (int i = 0; i <= n; ++i) {
            if (isP[i]) {
                p.add(i);
            }
        }

        int cnt = 0;
        for (int i = 0; i < p.size(); ++i) {
            int num = p.get(i) - 1;

            for (int j = 0; j < p.size() - 1; ++j) {
                if (p.get(j) + p.get(j+1) == num) {
                    ++cnt;
                    break;
                }
            }
        }

        if (cnt >= k) {
            out.println("YES");
        }
        else {
            out.println("NO");
        }
        out.flush();
    }
}


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

public class Primes
{
	static Scanner in = new Scanner( new BufferedReader( new InputStreamReader( System.in ) ) );

	public static void main( String[] args )
	{
		int n = in.nextInt(), k = in.nextInt(), count = 0;
		boolean[] isP = new boolean[n+1];
		for( int i = 2; i <= n; i++ ) isP[i] = true;
		ArrayList<Integer> primes = new ArrayList<Integer>();
		for( int i = 2; i <= n; i++ ) if( isP[i] )
		{
			primes.add(i);
			if( i <= Math.sqrt(n) ) for( int j = 2*i; j <= n; j += i ) isP[j] = false;
		}
		for( int i = 0; i < primes.size()-1; i++ )
		{
			int sum = primes.get(i)+primes.get(i+1)+1;
			if( sum<=n && isP[sum] ) count++;
		}
		if( count>=k ) System.out.println( "YES" );
		else System.out.println( "NO" );
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;

public class B {
	static ArrayList<Integer> [] adj;
	static int [] num;
	static int dfs(int u, int p){
		int cnt = 0;
		for(int v:adj[u]){
			if(v != p)
				cnt += dfs(v, u);
		}
		if(adj[u].size() == 1 && u != 0 || u == 0 && adj[0].size() == 0)
			cnt++;
		num[cnt]++;
		return cnt;
	}
	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		adj = new ArrayList[n];
		for (int i = 0; i < adj.length; ++i) {
			adj[i] = new ArrayList<>();
		}
		for (int i = 1; i < n; ++i) {
			int p = sc.nextInt()-1;
			adj[p].add(i);
			adj[i].add(p);
		}
		num = new int[n+1];
		dfs(0, -1);
		for (int i = 1; i < num.length; ++i) {
			num[i] += num[i-1];
		}
		int cur = 1;
		for (int i = 0; i < num.length; ++i) {
			while(cur <= num[i]){
				out.print(i + " ");
				++cur;
			}
		}
		out.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
	}

}


import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.min;
import static java.lang.System.exit;

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

public class F {

	static void solve() throws Exception {
		int n = scanInt();
		long l[] = new long[n];
		for (int i = 0; i < n; i++) {
			l[i] = scanLong();
		}
		long e1 = 0, e2 = 0, ans = 0;
		boolean water = false;
		String types = scanString();
		for (int i = 0; i < n; i++) {
			long li = l[i], cur;
			switch (types.charAt(i)) {
			case 'G':
				cur = min(e1, li);
				e1 -= cur;
				li -= cur;
				e2 += 2 * cur;
				ans += 2 * cur;
				e2 += li;
				ans += 3 * li;
				break;
			case 'W':
				water = true;
				e1 += li;
				ans += 2 * li;
				break;
			case 'L':
				cur = min(e1, li);
				e1 -= cur;
				li -= cur;
				ans += 2 * cur;
				cur = min(e2, li);
				e2 -= cur;
				li -= cur;
				ans += 3 * cur;
				ans += (water ? 4 : 6) * li;
				break;
			default:
				throw new AssertionError();
			}
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

1091_F. New Year and the Mallard Expedition


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

public class Main
{
    static final long mod=(int)1e9+7;
    public static void main(String[] args) throws Exception
    {
    	FastReader in=new FastReader();
    	PrintWriter pw=new PrintWriter(System.out);
    	int n=in.nextInt();
    	long ans=0;
    	for(int i=2;2*i<=n;i++)
    	{
    		ans+=i*(n/i-1);
    	}
    	ans*=4;
    	pw.print(ans);
    	pw.flush();
    }
}

class pair
{
	int f,s;
}

class FastReader
{
    BufferedReader br;
    StringTokenizer st;

    public FastReader()
    {
        br=new BufferedReader(new InputStreamReader(System.in));
    }

    public String next() throws IOException
    {
        if(st==null || !st.hasMoreElements())
        {
            st=new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C {

	public static int mod = 1000000000 + 7;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String n = br.readLine();
		int k = Integer.parseInt(br.readLine());
		int l = n.length();

		if(k == 0) {
			System.out.println(1);
		}else {
			int max = 1000;
			if (l <= 10) {
				max = Integer.min(1000, Integer.parseInt(n, 2));
			}

			int[] steps = new int[max + 1];

			for (int i = 2; i <= max; i++) {
				int ones = numberOfOnes(i);
				steps[i] = 1 + steps[ones];
			}

			if (l <= 10) {
				int ans = 0;
				for (int i = 1; i <= max; i++) {
					if (steps[i] == k) {
						ans++;
					}
				}
				System.out.println(ans);
			} else {
				int[][] C = binomial(max);

				int ans = 0;
				int count = 0;

				for (int i = 0; i < l; i++) {
					if (n.charAt(i) == '1') {
						for (int j = count; j < max; j++) {
							if (steps[j] == k - 1) {
								ans = (ans + C[l - i - 1][j - count]) % mod;
								if (i == 0 && k == 1) {
									ans = (ans + mod - 1) % mod;
								}
							}
						}
						count++;
					}
				}

				int ones = 0;
				for (int i = 0; i < l; i++) {
					if (n.charAt(i) == '1') {
						ones++;
					}
				}
				if (steps[ones] == k-1) {
					ans = (ans + 1) % mod;
				}

				System.out.println(ans);
			}
		}
	}

	public static int numberOfOnes(int x) {
		char[] s = Integer.toBinaryString(x).toCharArray();
		int count = 0;
		for (char c : s) {
			if (c == '1') {
				count++;
			}
		}
		return count;
	}

	public static int[][] binomial(int n) {
		int[][] C = new int[n + 1][n + 1];

		for (int i = 0; i <= n; i++) {
			C[i][0] = 1;
			for (int j = 1; j <= i; j++) {
				C[i][j] = ((C[i - 1][j - 1] % mod) + (C[i - 1][j] % mod)) % mod;
			}
		}

		return C;
	}

}

914_C. Travelling Salesman and Special Numbers


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

       public static void main(String args[]){
              Scanner sc = new Scanner(System.in);
              int n = sc.nextInt();
              int ans = 0;
              for(int i = 1; i <= n; i++){
                     ans += ((i*2) <= n) ? i : n-i+1;
              }
              System.out.println(ans);
       }
}


import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	 int[][] x = new int [200010][10];
     String a = sc.nextLine();
     String b = sc.nextLine();
 	  int n = a.length();
	  int m = b.length();
       for (int i = 1; i <= m; i++) {
         for (int j = 0; j < 2; j++) {
           x[i][j] = x[i - 1][j];
         }
         ++x[i][b.charAt(i - 1) - '0'];
       }
       long res = 0;
        for (int i = 0, c; i < n; i++) {
          c = a.charAt(i) - '0';
           for (int j = 0; j < 2; j++) {
             res += Math.abs(c - j) * (x[m - n + i + 1][j] - x[i][j]);
           }
        }
         System.out.println(res);
  }
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;

public class TaskB implements Runnable {
    boolean prime[] = new boolean[(int)1e6+10];
    InputReader c;
    PrintWriter w;

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

        char a[] = c.next().toCharArray(), b[] = c.next().toCharArray();
        int n = a.length, m = b.length;

        int[][] prefix = new int[m][2];
        for(int i=0;i<m;i++){
            if(i!=0) {
                prefix[i][0] = prefix[i-1][0];
                prefix[i][1] = prefix[i-1][1];
            }
            prefix[i][b[i] - '0']++;
            //w.println(prefix[i][0]+" "+prefix[i][1]);
        }

        long res = 0;
        for(int i=0;i<n;i++){
            int temp = a[i] - '0';

            res += prefix[m - n + i][temp^1];
            if(i!=0) res -= prefix[i-1][temp^1];
        }

        w.println(res);

        w.close();
    }

    void sieveOfEratosthenes(int n) {
        for(int i=0;i<n;i++)
            prime[i] = true;

        for(int p = 2; p*p <=n; p++)
        {
            if(prime[p] == true)
            {
                for(int i = p*p; i <= n; i += p)
                    prime[i] = false;
            }
        }
    }
    class pair implements Comparable<pair>{
        char ch;
        int ind;

        @Override
        public String toString() {
            return "pair{" +
                    "ch=" + ch +
                    ", ind=" + ind +
                    '}';
        }

        public pair(char ch, int ind) {
            this.ch = ch;
            this.ind = ind;
        }
        public int compareTo(pair car) {
            if(this.ch==car.ch)
                return this.ind - car.ind;
            return this.ch - car.ch;
        }
    }
    public static void sortbyColumn(int arr[][], int col){
        Arrays.sort(arr, new Comparator<int[]>()
        {
            public int compare(int[] o1, int[] o2){
                return(Integer.valueOf(o1[col]).compareTo(o2[col]));
            }
        });

    }
    static long gcd(long a, long b){
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }
    public static class DJSet {
        public int[] upper;
        public DJSet(int n) {
            upper = new int[n];
            Arrays.fill(upper, -1);
        }

        public int root(int x) {
            return upper[x] < 0 ? x : (upper[x] = root(upper[x]));
        }

        public boolean equiv(int x, int y) {
            return root(x) == root(y);
        }

        public boolean union(int x, int y) {
            x = root(x);
            y = root(y);
            if (x != y) {
                if (upper[y] < upper[x]) {
                    int d = x;
                    x = y;
                    y = d;
                }
                upper[x] += upper[y];
                upper[y] = x;
            }
            return x == y;
        }
    }
    public static int[] radixSort(int[] f) {
        int[] to = new int[f.length];
        {
            int[] b = new int[65537];
            for(int i = 0;i < f.length;i++)b[1+(f[i]&0xffff)]++;
            for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
            for(int i = 0;i < f.length;i++)to[b[f[i]&0xffff]++] = f[i];
            int[] d = f; f = to;to = d;
        }
        {
            int[] b = new int[65537];
            for(int i = 0;i < f.length;i++)b[1+(f[i]>>>16)]++;
            for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
            for(int i = 0;i < f.length;i++)to[b[f[i]>>>16]++] = f[i];
            int[] d = f; f = to;to = d;
        }
        return f;
    }
    public void printArray(int[] a){
        for(int i=0;i<a.length;i++)
            w.print(a[i]+" ");
        w.println();
    }
    public int[] scanArrayI(int n){
        int a[] = new int[n];
        for(int i=0;i<n;i++)
            a[i] = c.nextInt();
        return a;
    }
    public long[] scanArrayL(int n){
        long a[] = new long[n];
        for(int i=0;i<n;i++)
            a[i] = c.nextLong();
        return a;
    }
    public void printArray(long[] a){
        for(int i=0;i<a.length;i++)
            w.print(a[i]+" ");
        w.println();
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        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() {
            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);
        }
    }
    public static void main(String args[]) throws Exception {
        new Thread(null, new TaskB(),"TaskB",1<<26).start();
    }
}


import java.util.Scanner;

public class HammingDistancesSum {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String  a = sc.nextLine(), b = sc.nextLine();
		long sum = 0;
		int frequency[][] = new int[200010][2];
		for (int i = 1; i <= b.length(); i++) {
	        for (int j = 0; j < 2; j++)
	            frequency[i][j] = frequency[i - 1][j];
	        frequency[i][Character.getNumericValue((b.charAt(i - 1)))]++;
	    }

	    for (int i = 0; i < a.length(); i++) {
	        int c = Character.getNumericValue(a.charAt(i));
	        for (int j = 0; j < 2; j++) {
	        	int flippingTerm = Math.abs(c - j);
	        	int endOfWindowValue = frequency[b.length() - a.length() + i + 1][j];
	        	int startOfWindowOffset = frequency[i][j];
	            sum += flippingTerm * (endOfWindowValue - startOfWindowOffset);
	        }
	    }
		System.out.println(sum);
		sc.close();
	}
}


/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	static int check(int temp)
	{
		int count1 = 0;
    while (temp>0)
    {
        if(temp % 2 != 0)
        count1++;
        temp/= 2;
    }
    return count1;
	}
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		String a=sc.next();
		String b=sc.next();
		int m=a.length();
		int n=b.length();
		int[] zero=new int[n];
		int[] one=new int[n];

		for(int i=0;i<n;i++)
		{
			if(i==0)
			{
				if(b.charAt(i)=='0')
				zero[i]++;
				else
				one[i]++;
			}
			else
			{
				zero[i]=zero[i-1];
				one[i]=one[i-1];
				if(b.charAt(i)=='0')
				zero[i]++;
				else
				one[i]++;
		    }
		}

		long res=0;
		for(int i=0;i<m;i++)
		{
		int x=n-m+i;
		if(a.charAt(i)=='0')
		res+=one[x];
		else
		res+=zero[x];
		if(i>0)
		{
			if(a.charAt(i)=='0')
			res-=one[i-1];
			else
			res-=zero[i-1];
		}
		}

		System.out.println(res);
	}
}


import java.io.*;
import java.lang.*;
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main {

    Main() throws IOException {
        String a = nextLine();
        String b = nextLine();
        long ans = 0;
        int s = 0;
        for (int i = 0; i < b.length() - a.length(); ++i) {
            s += b.charAt(i) == '1' ? 1 : 0;
        }

        for (int i = 0; i < a.length(); ++i) {
            s += b.charAt(i + b.length() - a.length()) == '1' ? 1 : 0;
            ans += a.charAt(i) == '1' ? b.length() - a.length() + 1 - s : s;
            s -= b.charAt(i) == '1' ? 1 : 0;
        }
        out.println(ans);
    }

    //////////////////////////////
    PrintWriter out = new PrintWriter(System.out, false);
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer stok = null;
    String nextLine() throws IOException {
        while (stok == null || !stok.hasMoreTokens()) {
            stok = new StringTokenizer(in.readLine());
        }
        return stok.nextToken();
    }

    public static void main(String args[]) throws IOException {
        if (args.length > 0) {
            setIn(new FileInputStream(args[0] + ".inp"));
            setOut(new PrintStream(args[0] + ".out"));
        }
        Main solver = new Main();
        solver.out.flush();  //  could be replace with a method, but nah, this is just competitive programming :p
    }
}


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.io.StreamTokenizer;
import java.util.Arrays;

public class B {

	// -- DEBUG switch --
	static final boolean DBG = false;
	static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	static int[] e = new int[100001];

	public static void main(String[] args) throws IOException {
		int n = i(), k = i(), cnt = 0;
		int[] a = new int[n+1];
		for (int i=1; i<=n; i++){
			a[i] = i();
			if (e[a[i]] == 0)
				cnt++;
			e[a[i]]++;
		}
		if (k > cnt){
			pw.println("-1 -1");
			pw.close();
			return;
		}
		if (cnt == n){
			pw.print("1 " + k);
			pw.close();
			return;
		}
		if (k == 1){
			pw.println("1 1");
			pw.close();
			return;
		}
		Arrays.fill(e, 0);
		int i = 1, j = 0, unik = 0, start = 0, end = 0, len = n, m = 0;

		if (e[a[i]] == 0){
			unik++;
		}
		e[a[i]]++;
		while (i+1<=n && a[i+1] == a[i]){
			i = i+1;
		}

		j = i+1;

		while (j <= n){
			if (e[a[j]] == 0){
				unik++;
				if (unik == k){
					while (e[a[i]] > 1){
						e[a[i]]--;
						i++;
						while (i+1<=n && a[i+1] == a[i]){
							i = i+1;
						}
					}
					m = j - i + 1;
					if (m < len){
						start = i; end = j; len = m;
						if (m == k)
							break;
					}

					while (i <=n && unik == k){
						e[a[i]]--;
						if (e[a[i]] == 0)
							unik--;
						i++;

						while (i+1<=n && a[i+1] == a[i]){
							i = i+1;
						}
					}

				}
			}
			e[a[j]]++;
			while (j+1<=n && a[j+1] == a[j]){
				j++;
			}
			j++;

		}
		pw.println(start + " " + end);
		pw.close();
	}

	static int i() throws IOException{
		st.nextToken();
		return (int)st.nval;
	}

	static long l() throws IOException {
		st.nextToken();
		return (long)st.nval;
	}

	static double d() throws IOException {
		st.nextToken();
		return st.nval;
	}
	static String s() throws IOException{
		st.nextToken();
		return st.sval;
	}
}


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

public class Array {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		/*
		if ( k == 1 ){
			System.out.println("1 1"); return;
		}
		*/
		int last[] = new int[100001];
		int distinct = 0;
		for ( int i = 0 ; i < n ; ++i ) {
			int t = in.nextInt();
			if ( last[t] == 0 ) ++distinct;
			last[t] = i+1;
			if ( distinct == k ) {
				int min = i+1;
				for ( int j = 0 ; j < last.length ; ++j ) {
					if ( last[j] != 0 ) min = min>last[j]?last[j]:min;
				}
				System.out.println(min+" "+(i+1)); return;
			}
		}
		System.out.println("-1 -1");
	}

}


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

public class C_138B {
	private static BufferedReader in;
	private static StringTokenizer st;
	private static PrintWriter out;

	static String nextToken() throws IOException {
		while (!st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	static int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}
	public static void main(String[] args) throws NumberFormatException, IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		st = new StringTokenizer("");
		out = new PrintWriter(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();
		}
		Set<Integer> set = new HashSet<Integer>();
		for (int i = 0; i < a.length; i++) {
			set.add(a[i]);
			if(set.size()==k){
				Set<Integer> set2 = new HashSet<Integer>();
				for (int j = i; j >= 0; j--) {
					set2.add(a[j]);
					if(set2.size()==k){
						out.print((j+1)+" "+(i+1));
						out.close();
						return;
					}
				}
			}
		}
		out.print("-1 -1");
		out.close();
	}
}


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

public class Array {

    void run() {
        try {
            BufferedReader bfd = new BufferedReader(new InputStreamReader(
                    System.in));
            StringTokenizer tk = new StringTokenizer(bfd.readLine());
            int n = Integer.parseInt(tk.nextToken());
            int k = Integer.parseInt(tk.nextToken()), i;
            int arr[] = new int[n];
            tk = new StringTokenizer(bfd.readLine());
            for(i=0;i<n;++i)
                arr[i] = Integer.parseInt(tk.nextToken());
            int dist=0,l=0,r=0;
            HashSet<Integer> hs = new HashSet<Integer>();
            for(i=0; i<n; ++i) {
                if(!hs.contains(arr[i])){
                    hs.add(arr[i]);
                    dist++;
                }
                if(dist==k) break;
                r++;
            }
            int freq[] = new int[100010];
            if(hs.size()<k) System.out.println("-1 -1");
            else {
                while(l<arr.length-1 && l<r && arr[l]==arr[l+1])
                    ++l;
                while(r>=1 && r>l && arr[r]==arr[r-1])
                    --r;
                for(i=l;i<=r;++i)
                    freq[arr[i]]++;
                while(freq[arr[l]]>1){
                    freq[arr[l]]--;
                    l++;
                }
                while(freq[arr[r]]>1){
                    freq[arr[r]]--;
                    r--;
                }
                System.out.println((l+1)+" " +(r+1));
            }
        } catch (Exception e) {

        }
    }
    public static void main(String[] args) {
        new Array().run();
    }

}


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

public class B implements Runnable {

	void Solution() throws IOException {
		int n = nextInt(), k = nextInt();
		int[] mas = new int[n];
		for (int i = 0; i < n; i++)
			mas[i] = nextInt();
		int l = 0, r = 0;
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		map.put(mas[l], 1);
		int cur = 1;
		while (true) {
			if (cur == k) {
				print(l + 1, r + 1);
				return;
			}
			r++;
			if (r >= n)
				break;
			int kol = map.containsKey(mas[r]) ? map.remove(mas[r]) : 0;
			if (kol == 0) {
				cur++;
				map.put(mas[r], 1);
			} else
				map.put(mas[r], kol + 1);
			while (true) {
				kol = map.remove(mas[l]);
				if (kol == 1) {
					map.put(mas[l], 1);
					break;
				} else
					map.put(mas[l++], kol - 1);
			}
		}
		print(-1, -1);
	}

	public static void main(String[] args) {
		new B().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tokenizer;

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			Solution();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(0);
		}
	}

	void print(Object... obj) {
		for (int i = 0; i < obj.length; i++) {
			if (i != 0)
				out.print(" ");
			out.print(obj[i]);
		}
	}

	void println(Object... obj) {
		print(obj);
		out.println();
	}

	void halt() {
		out.close();
		System.exit(0);
	}

	String nextLine() throws IOException {
		return in.readLine();
	}

	String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(nextLine());
		return tokenizer.nextToken();
	}

	int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(next());
	}

	long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(next());
	}

	double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(next());
	}
}


import java.io.*;
import java.util.*;
public class B {
	static int i(String s) { return Integer.parseInt(s); }
	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] arr = in.readLine().split(" ");
		int n = i(arr[0]);
		int k = i(arr[1]);
		int[] A = new int[n];
		arr = in.readLine().split(" ");
		for(int i=0; i<n; i++)
			A[i] = i(arr[i]);

		int st = 0;
		int cnt = 0;
		int[] cnts = new int[100*100*10+1];
		for(int i=0; i<n; i++) {
			cnts[A[i]]++;
			if(cnts[A[i]] == 1) cnt++;
			else while(cnts[A[st]] > 1) {
				cnts[A[st]]--;
				st++;
			}
			if(cnt == k) {
				System.out.println((st+1)+" "+(i+1));
				return;
			}
		}
		System.out.println(-1+" "+-1);
	}
}


import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class B {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int distinct = sc.nextInt();
        HashMap<Integer, Integer> set = new HashMap<Integer, Integer>();
        int[] ar = new int[n];
        for (int i = 0; i < n; i++) {
            ar[i] = sc.nextInt();
            if (set.containsKey(ar[i])) {
                set.put(ar[i], set.get(ar[i])+1);
            } else {
                set.put(ar[i], 1);
            }
            if (set.size() == distinct) {
                int st = 0;
                for (int j = 0; j < i; j++) {
                    st=j;
                    if (set.get(ar[j]) > 1) {
                        set.put(ar[j], set.get(ar[j]) - 1);
                    } else {
                        break;
                    }
                }
                System.out.println((st + 1) + " " + (i + 1));
                return;
            }
        }
        System.out.println("-1 -1");
    }
}


import java.util.Scanner;

public class B {

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

		int[] a = new int[n+1];
		int[] d = new int[100001];

		int tk = 0;
		int l = 1;
		int r = -1;
		boolean find = false;
		for (int i = 1; i <= n; i++){
			a[i] = scr.nextInt();
			if (d[a[i]] == 0){
				d[a[i]] = 1;
				tk++;
				if ((!find) && (tk == k)){
					find = true;
					r = i;
				} // if
			} // if
		} // for

		if (r > 0) {
			int[] cd = new int[100001];
			tk = 0;
			find = false;
			for (int j = r; j >= l; j--){
				if(cd[a[j]] == 0){
					cd[a[j]] = 1;
					tk++;
					if ((!find) && (tk == k)){
						find = true;
						l = j;
						break;
					} // if
				} // if
			} // for
			System.out.println(l + " " + r);
		} // if
		else {
			System.out.println("-1 -1");
		}

	}

}


import java.util.*;
import java.io.*;
public class B {
	public void solve() throws IOException {
		int n = nextInt();
		int k = nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
			a[i] = nextInt();
		}
		int[] num = new int[n];
		Set<Integer> set = new HashSet<Integer>();
		int s = -1;
		int l = -1;
		for(int i = 0; i < n; i++){
			set.add(a[i]);
			num[i] = set.size();
			if( num[i] == k ){
				l = i+1;
				set = new HashSet<Integer>();
				for(int j = i; j >= 0; j--){
					set.add(a[j]);
					if( set.size() == k ){
						s = j+1;
						break;
					}
				}
				break;
			}
		}
		writer.println(s + " " + l);
 	}

	public static void main(String[] args) throws IOException {
		new B().run();
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() throws IOException {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class PrB {

	public static long time;

	public static void main(String[] args) throws Exception {
		time = System.currentTimeMillis();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());
		k = Integer.parseInt(st.nextToken());
		a = new int[n];
		st = new StringTokenizer(br.readLine());
		for(int i = 0; i < n; i++)
			a[i] = Integer.parseInt(st.nextToken());
		int end = end();
		if(end < 0) System.out.println("-1 -1");
		else System.out.println((start(end) + 1) + " " + (end + 1));
		br.close();
		System.exit(0);
	}

	static int n, k;
	static int[] a;

	public static int end() throws Exception {
		boolean[] reached = new boolean[100002];
		int rem = k;
		for(int i = 0; i < n; i++) {
			if(!reached[a[i]]) {
				rem--;
				if(rem == 0) return i;
			}
			reached[a[i]] = true;
		}
		return -1;
	}

	public static int start(int end) throws Exception {
		boolean[] reached = new boolean[100002];
		int rem = k;
		for(int i = end; i >= 0; i--) {
			if(!reached[a[i]]) {
				rem--;
				if(rem == 0) return i;
			}
			reached[a[i]] = true;
		}
		return 0;
	}

	public static void checkTime() {
		System.out.println(System.currentTimeMillis() - time);
		time = System.currentTimeMillis();
	}
}