import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {

    FastScanner in = new FastScanner(System.in);
//    FastScanner in = new FastScanner(new File("test.txt"));

    PrintWriter out = new PrintWriter(System.out);

    public static void main (String[]args) {
        Main task = new Main();
        task.solve();
        task.close();
    }

    public void close () {
        in.close();
        out.close();
    }

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

        Team[]teams = new Team[n];

        for (int i = 0; i < n; i++) {
            Team t = new Team();
            t.tasks = in.nextInt();
            t.penalty = in.nextInt();
            teams[i] = t;
        }

        Arrays.sort(teams);

        Team t = teams[k - 1];
        int ans = 0;
        for (int i = 0; i < teams.length; i++) {
            if (teams[i].equals(t)) ans++;
        }

        System.out.println(ans);

    }
    class Team implements Comparable<Team>{
        int tasks;
        int penalty;
        @Override
        public int hashCode() {
            final int prime = 31;
            int result = 1;
            result = prime * result + getOuterType().hashCode();
            result = prime * result + penalty;
            result = prime * result + tasks;
            return result;
        }
        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            Team other = (Team) obj;
            if (!getOuterType().equals(other.getOuterType()))
                return false;
            if (penalty != other.penalty)
                return false;
            if (tasks != other.tasks)
                return false;
            return true;
        }
        @Override
        public int compareTo(Team o) {
            if (this.tasks > o.tasks) return -1;
            else if (this.tasks == o.tasks) {
                if (this.penalty <= o.penalty) return -1;
                else return 1;
            }
            else return 1;
        }
        private Main getOuterType() {
            return Main.this;
        }

    }

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

}

class Algebra {
    /****
     *       Number of co-prime numbers on [1, n].
     *       Number a is Co-prime if gcd (a, n) == 1
     *       O (sqrt(n))
     ****/
    public static int phi(int n) {
        int result = n;
        for (int i = 2; i*i <= n; ++i) {
            if (n % i == 0) {
                while (n % i == 0) {
                    n /= i;
                }
                result -= result / i;
            }
        }
        if (n > 1) {
            result -= result / n;
        }
        return result;
    }

    /****
     *       Raise number a to power of n.
     *       O (log n)
     ****/
    public static int binpow (int a, int n) {
        int res = 1;
        while (n != 0) {
            if ((n & 1) == 1)
                res *= a;
            a *= a;
            n >>= 1;
        }
        return res;
    }

    /****
     *       Finding the greatest common divisor of two numbers.
     *       O (log min(a, b))
     ****/
    public static int gcd (int a, int b) {
        return (b != 0) ? gcd (b, a % b) : a;
    }

    /****
     *       Finding the lowest common multiple of two numbers.
     *       O (log min(a, b))
     ****/
    public static int lcm (int a, int b) {
        return a / gcd (a, b) * b;
    }

    /****
     *       Eratosthenes Sieve of numbers - [0..n]. True - simple, False - not simple.
     *       O (n log log n)
     ****/
    public static boolean[] sieveOfEratosthenes (int n) {
        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]) {
                if (i * 1L * i <= n) {
                    for (int j=i*i; j<=n; j+=i) {
                        prime[j] = false;
                    }
                }
            }
        }
        return prime;
    }
}

class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    FastScanner(File f) {
        try {
            br = new BufferedReader(new FileReader(f));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    FastScanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(in));
    }

    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                System.err.println(e);
                return "";
            }
        }
        return st.nextToken();
    }

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

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

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

    float nextFloat() {
        return Float.parseFloat(next());
    }
    BigInteger nextBigInt() {
        return new BigInteger(next());
    }

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


import java.io.*;
import java.security.SecureRandom;
import java.util.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {

    class Pair implements Comparable<Pair> {

        int col;
        int time;
        int place;

        public Pair() {

        }

        public Pair(int col, int time) {
            this.col = col;
            this.time = time;
        }

        @Override
        public int compareTo(Pair arg0) {
            if (col == arg0.col) {
                return time - arg0.time;
            }
            return arg0.col - col;
        }

    }

    public void solve() throws Exception {
        int n = sc.nextInt();
        int k = sc.nextInt();

        ArrayList<Pair> a = new ArrayList<Pair>();

        for (int i = 0;i < n; ++ i) {
            a.add(new Pair(sc.nextInt(), sc.nextInt()));
        }
        Collections.sort(a);

        int place = 1;
        int placex = 0;
        int ans2 = 0;
        int ans1 = 0;

        for (int i = 0;i < n; ++ i) {
            if (i > 0 && a.get(i).compareTo(a.get(i - 1)) != 0) {
                ++ place;
                ++ placex;
            } else {
                ++ placex;
            }
            a.get(i).place = place;
            if (placex == k) {
                ans1 = place;
            }
        }

        for (int i = 0;i < n; ++ i) {
            if (a.get(i).place == ans1) {
                ++ ans2;
            }
        }

        out.println(ans2);
    }

    /*--------------------------------------------------------------*/

    static String filename = "";
    static boolean fromFile = false;

    BufferedReader in;
    PrintWriter out;
    FastScanner sc;

    public static void main(String[] args) {
        new Thread(null, new Solution(), "", 1 << 25).start();
    }

    public void run() {
        try {
            init();
            solve();
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            out.close();
        }
    }

    void init() throws Exception {
        if (fromFile) {
            in = new BufferedReader(new FileReader(filename+".in"));
            out = new PrintWriter(new FileWriter(filename+".out"));
        } else {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
        sc = new FastScanner(in);
    }
}

class FastScanner {

    BufferedReader reader;
    StringTokenizer strTok;

    public FastScanner(BufferedReader reader) {
        this.reader = reader;
    }

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

        return strTok.nextToken();
    }

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

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

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

    public BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    public BigDecimal nextBigDecimal() throws IOException {
        return new BigDecimal(nextToken());
    }
}


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

public class Solution
{
    public static void main(String[] args) throws IOException
    {
        new Solution().run();
    }
    StreamTokenizer in;
    Scanner ins;
    PrintWriter out;

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

    void run() throws IOException
    {

        if(System.getProperty("ONLINE_JUDGE")!=null)
        {
            in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
            ins = new Scanner(System.in);
            out = new PrintWriter(System.out);
        }
        else
        {
            in = new StreamTokenizer(new BufferedReader(new FileReader("input.txt")));
            ins = new Scanner(new FileReader("input.txt"));
            out = new PrintWriter(new FileWriter("output.txt"));
        }
        int n = nextInt(),k = nextInt();
        Team[] A = new Team[n];
        for(int i = 0; i < n; i++)
        {
            A[i] = new Team();
            A[i].p = nextInt(); A[i].t = nextInt();
        }
        Arrays.sort(A);

        k--;
        int sum = 0;
        for(int i = 0; i < n; i++)
            if(A[k].compareTo(A[i])==0)
                sum++;

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

    class Team implements Comparable
    {
        public int p,t;
        public int compareTo(Object obj)
        {
            Team a = (Team) obj;
            if(p>a.p || p==a.p && t<a.t)
                return -1;
            else
                if(p==a.p && t==a.t)
                    return 0;
                else
                    return 1;
        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ProblemA {

    private final BufferedReader in;
    private final PrintStream out;
    private StringTokenizer tok = new StringTokenizer("");
    private String nextLine = null;

    public static void main(String[] args) throws Exception {
        new ProblemA();
    }

    private ProblemA() throws Exception {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = System.out;
        start();
        end();
    }

    private int nextInt() {
        return Integer.parseInt(nextWord());
    }

    private String nextWord() {
        if (tok.hasMoreTokens()) {
            return tok.nextToken();
        } else {
            while (!tok.hasMoreTokens()) {
                try {
                    nextLine = in.readLine();
                    if (nextLine == null) {
                        return null;
                    } else {
                        tok = new StringTokenizer(nextLine);
                    }
                } catch (IOException ex) {
                    Logger.getLogger(ProblemA.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            return tok.nextToken();
        }
    }

    private void start() {
        int n = nextInt();
        int k = nextInt();
        T[] ts = new T[n];
        for (int i = 0; i < n; i++) {
            ts[i] = new T(nextInt(), nextInt());
        }
        Arrays.sort(ts, new Comparator<T>() {

            @Override
            public int compare(T o1, T o2) {
                if (o1.p > o2.p) {
                    return -1;
                }
                if (o1.p < o2.p) {
                    return 1;
                }
                if (o1.t < o2.t) {
                    return -1;
                }
                if (o1.t > o2.t) {
                    return 1;
                }
                return 0;
            }
        });
        int t = ts[k - 1].t;
        int p = ts[k - 1].p;
        int res = 0;
        for (int i = 0; i < n; i++) {
            if (ts[i].p == p && ts[i].t == t) {
                res++;
            }
        }
        out.println(res);
    }

    class T {

        int p;
        int t;

        public T(int p, int t) {
            this.p = p;
            this.t = t;
        }
    }

    private void end() {
        out.close();
    }
}


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

public class Main
{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer tokenizer=null;

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

	void debug(Object...os)
	{
		System.out.println(Arrays.deepToString(os));
	}

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

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

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

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

	String nline() throws IOException
	{
		tokenizer=null;
		return br.readLine();
	}

	//Main Code starts Here
	int totalCases, testNum;
	int k,n;

	void execute() throws IOException
	{
		totalCases = 1;
		for(testNum = 1; testNum <= totalCases; testNum++)
		{
			input();
			solve();
		}
	}

	void solve()
	{
		int a = arr[k-1].a;
		int b = arr[k-1].b;
		//debug(a,b);
		int count = 0;
		for(int i = 0;i<n;i++)
		{
			if(arr[i].a == a && arr[i].b == b)
				count++;
		}
		System.out.println(count);
	}

	void printarr(int [] a,int b)
	{
		for(int i = 0;i<=b;i++)
		{
			if(i==0)
				System.out.print(a[i]);
			else
				System.out.print(" "+a[i]);
		}
		System.out.println();
	}

	class Pair implements Comparable<Pair>
{
	int a,b;
	Pair(int _a,int _b)
	{
		a=_a;
		b=_b;
	}

	public int compareTo(Pair x)
	{
		if(a == x.a) return b-x.b;
		return -(a-x.a);
	}

	public boolean equals(Pair x)
	{
		return a==x.a && b==x.b;
	}
}

	Pair[] arr;
	boolean input() throws IOException
	{
		n = ni();
		k = ni();
		arr = new Pair[n];
		for(int i = 0 ;i<n;i++)
		{
			Pair p =new Pair(ni(),ni());
			arr[i]  = p;
		}
		Arrays.sort(arr);
		//debug(arr);
		return true;
	}
}


import java.awt.Point;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class Start {

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        if (ONLINE_JUDGE) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

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

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

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

    public static void mergeSort(int[] a) {
        mergeSort(a, 0, a.length - 1);
    }

    private static void mergeSort(int[] a, int levtIndex, int rightIndex) {
        final int MAGIC_VALUE = 50;
        if (levtIndex < rightIndex) {
            if (rightIndex - levtIndex <= MAGIC_VALUE) {
                insertionSort(a, levtIndex, rightIndex);
            } else {
                int middleIndex = (levtIndex + rightIndex) / 2;
                mergeSort(a, levtIndex, middleIndex);
                mergeSort(a, middleIndex + 1, rightIndex);
                merge(a, levtIndex, middleIndex, rightIndex);
            }
        }
    }

    private static void merge(int[] a, int levtIndex, int middleIndex,
            int rightIndex) {
        int length1 = middleIndex - levtIndex + 1;
        int length2 = rightIndex - middleIndex;
        int[] levtArray = new int[length1];
        int[] rightArray = new int[length2];
        System.arraycopy(a, levtIndex, levtArray, 0, length1);
        System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
        for (int k = levtIndex, i = 0, j = 0; k <= rightIndex; k++) {
            if (i == length1) {
                a[k] = rightArray[j++];
            } else if (j == length2) {
                a[k] = levtArray[i++];
            } else {
                a[k] = levtArray[i] <= rightArray[j] ? levtArray[i++]
                        : rightArray[j++];
            }
        }
    }

    private static void insertionSort(int[] a, int levtIndex, int rightIndex) {
        for (int i = levtIndex + 1; i <= rightIndex; i++) {
            int current = a[i];
            int j = i - 1;
            while (j >= levtIndex && a[j] > current) {
                a[j + 1] = a[j];
                j--;
            }
            a[j + 1] = current;
        }
    }

    public void run() {
        try {
            long t1 = System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2 = System.currentTimeMillis();
            System.err.println("Time = " + (t2 - t1));
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    class Lol implements Comparable<Lol>{
        int x;
        int y;

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

            @Override
            public int compareTo(Lol arg0) {
                if (arg0.x == x) {
                    return y-arg0.y;
                }
                return arg0.x-x;
            }

    }

    public void solve() throws IOException {

        int n = readInt();
        int k = readInt();
        k--;
        Lol [] a = new Lol [n];

        for (int i  = 0 ; i  <n; i++){
            int x = readInt();
            int y = readInt();
            a[i] = new Lol(x, y);
        }
        Arrays.sort(a);
        int ans = 1;
        for (int i =k+1; i>-1; i++){
            if (i==n) break;
            if (a[i].x==a[k].x && a[i].y == a[k].y){
                ans++;
            }
            else break;
        }
        if (k!=0){
            for (int i =k-1; i>=0; i--){
                if (a[i].x==a[k].x && a[i].y == a[k].y){
                    ans++;
                }
                else break;
            }
        }
        out.print(ans);

    }
}


import java.util.*;

import java.io.*;
public class C{
		public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int n=in.nextInt(),key=in.nextInt(),ans=0;
		int[] a = new int[101], b = new int[101];
		for (int i=1;i<=n;i++) {a[i]=in.nextInt();b[i]=in.nextInt();}
		for (int i=1;i<n;i++)
			for (int j=i+1;j<=n;j++)
				if (a[i]<a[j] || (a[i]==a[j] && b[i]>b[j])) {
		int yed = a[i];a[i]=a[j];			a[j]=yed;
		yed = b[i];b[i]=b[j];b[j]=yed;
				}
		int k=0;

		for (int i=1;i<=n;i++) {
			if (a[i]==a[i-1] && b[i]==b[i-1]) k++; else
				{if (i>key && ans==0) ans = k;k=1;}

		}
		if (ans == 0) ans = k;
		System.out.println(ans);

		}
}


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

public class Main {
    public static void main(String[] args) {
        Scanner r = new Scanner(System.in);
        int N = r.nextInt();
        int K = r.nextInt() - 1;

        T[] a = new T[N];
        for(int i = 0; i < N; i++)
            a[i] = new T(r.nextInt(), r.nextInt());

        Arrays.sort(a, new Comparator<T>() {

            @Override
            public int compare(T x, T y) {
                if(x.p > y.p)return -1;
                else if(x.p == y.p){
                    if(x.t < y.t)return -1;
                    else if(x.t == y.t)return 0;
                    else return 1;
                }else return 1;
            }
        });

        int ret = 0;
        for(int i = 0; i < N; i++)
            if(a[i].p == a[K].p && a[i].t == a[K].t)ret++;

        System.out.println(ret);
    }
}

class T{
    int p, t;
    public T(int pi, int ti){
        p = pi;
        t = ti;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class ProblemA {
    public static class Team {
        int solved;
        int penalty;
        Team(int s, int p) {
            solved = s;
            penalty = p;
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        String[] data = s.readLine().split(" ");
        int n =  Integer.valueOf(data[0]);
        int k =  Integer.valueOf(data[1]);

        Team[] t = new Team[n];
        for (int i = 0 ; i < n ; i++) {
            String[] line = s.readLine().split(" ");
            t[i] = new Team(Integer.valueOf(line[0]), Integer.valueOf(line[1]));
        }
        Arrays.sort(t, new Comparator<Team>(){
            public int compare(Team arg0, Team arg1) {
                if (arg0.solved != arg1.solved) {
                    return arg1.solved - arg0.solved;
                }
                return arg0.penalty - arg1.penalty;
            }
        });

        int idx = k - 1;
        int ksol = t[idx].solved;
        int kpen = t[idx].penalty;
        int count = 0;
        for (int i = 0 ; i < n ; i++) {
            if (t[i].solved == ksol && t[i].penalty == kpen) {
                count++;
            }
        }
        System.out.println(count);
    }
}


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

public class A
{
	static class T
	{
		public int s,p;
	}
	public static void main(String args[]) throws Exception
	{
		InputReader sc=new InputReader(System.in);
		int n=sc.readInt(),k=sc.readInt(),i,j,z;
		T m[]=new T[n];
		for(i=0;i<n;i++) {m[i]=new T();m[i].s=sc.readInt();m[i].p=sc.readInt();}
		for(i=0;i<n;i++) for(j=i+1;j<n;j++)	if(m[i].s<m[j].s){z=m[i].s;m[i].s=m[j].s;m[j].s=z;z=m[i].p;m[i].p=m[j].p;m[j].p=z;}
		for(i=0;i<n;i++) for(j=i+1;j<n;j++)	if(m[i].s==m[j].s&&m[i].p>m[j].p){z=m[i].s;m[i].s=m[j].s;m[j].s=z;z=m[i].p;m[i].p=m[j].p;m[j].p=z;}
		k--;int s=m[k].s,p=m[k].p,res=0;
		for(i=0;i<n;i++){if(m[i].s==s&&m[i].p==p)res++;}
		System.out.println(res);
	}
}
class InputReader {
	private boolean finished = false;
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;

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

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

	public int peek() {
		if (numChars == -1)
			return -1;
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				return -1;
			}
			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) {
			if (c != '\r')
				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 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 == 'e' || c == 'E')
				return res * Math.pow(10, readInt());
			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, readInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				m /= 10;
				res += (c - '0') * m;
				c = read();
			}
		}
		return res * sgn;
	}

	public boolean isExhausted() {
		int value;
		while (isSpaceChar(value = peek()) && value != -1)
			read();
		return value == -1;
	}

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


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

public class AA {
	static class O implements Comparable<O> {
		int problems;
		int penalty;

		public O(int p, int pp) {
			problems = p;
			penalty = pp;
		}

		public int compareTo(O arg0) {
			if (problems == arg0.problems) {
				return penalty - arg0.penalty;
			}
			return -(problems - arg0.problems);
		}

	}

	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String s = r.readLine();
		String[] sp = s.split("[ ]+");
		int n = new Integer(sp[0]), k = new Integer(sp[1]) - 1;
		O[] arr = new O[n];
		for (int i = 0; i < arr.length; i++) {
			s = r.readLine();
			sp = s.split("[ ]+");
			arr[i] = new O(new Integer(sp[0]), new Integer(sp[1]));
		}
		Arrays.sort(arr);

		int res = 1;

		int i = k + 1;
		while (i < arr.length && arr[i].problems == arr[k].problems
				&& arr[i].penalty == arr[k].penalty) {
			i++;
			res++;
		}

		i = k - 1;
		while (i >= 0 && arr[i].problems == arr[k].problems
				&& arr[i].penalty == arr[k].penalty) {
			i--;
			res++;
		}
		System.out.println(res);

	}
}


import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.InputMismatchException;

public class R113_D2_A {

    public static void main(String[] args) throws NumberFormatException,
            IOException {
        // BufferedReader in = new BufferedReader(new
        // InputStreamReader(System.in));
        InputReader4 in = new InputReader4(System.in);
        int n = in.readInt();
        int k = in.readInt();
        p[] inp = new p[n];
        for (int i = 0; i < inp.length; i++) {
            inp[i] = new p(in.readInt(), in.readInt());
        }
        Arrays.sort(inp);
        for (int i = 0; i < inp.length;) {
            int j = i + 1;
            while (j < inp.length && inp[i].x == inp[j].x
                    && inp[i].y == inp[j].y) {
                j++;
            }
            int num = j - i;
            if (k <= num) {
                System.out.println(num);
                return;
            } else
                k -= num;
            i = j;
        }
    }

    static class p implements Comparable<p> {
        int x;
        int y;

        public p(int a, int b) {
            x = a;
            y = b;
        }

        public int compareTo(p o) {
            if (x > o.x)
                return -1;
            if (x < o.x)
                return 1;
            return y - o.y;
        }

    }

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

        public InputReader4(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 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 == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                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, readInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
    }

}


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

public class A
{
	String line;
	StringTokenizer inputParser;
	BufferedReader is;
	FileInputStream fstream;
	DataInputStream in;
	String FInput="";

	void openInput(String file)
	{

		if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
		else
		{
			try{

			fstream = new FileInputStream(file);
			in = new DataInputStream(fstream);
			is = new BufferedReader(new InputStreamReader(in));
			}catch(Exception e)
			{
				System.err.println(e);
			}
		}

	}

	void readNextLine()
	{
		try {
			line = is.readLine();
			inputParser = new StringTokenizer(line, " ");
			//System.err.println("Input: " + line);
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}
		catch (NullPointerException e)
		{
			line=null;

		}

	}

	int NextInt()
	{
		String n = inputParser.nextToken();
		int val = Integer.parseInt(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	long NextLong()
	{
		String n = inputParser.nextToken();
		long val = Long.parseLong(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	String NextString()
	{
		String n = inputParser.nextToken();
		return n;
	}

	void closeInput()
	{
		try {
			is.close();
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	public static void main(String [] argv)
	{
		String filePath=null;
		if(argv.length>0)filePath=argv[0];
		new A(filePath);
	}

	public void readFInput()
	{
		for(;;)
		{
			try
			{
				readNextLine();
				FInput+=line+" ";
			}
			catch(Exception e)
			{
				break;
			}
		}
		inputParser = new StringTokenizer(FInput, " ");
	}

	public A(String inputFile)
	{
		openInput(inputFile);

		readNextLine();
		int n=NextInt();
    	int k=NextInt()-1;
		int ret=0;
		Team [] t = new Team[n];
		for(int i=0; i<n; i++)
		{
			readNextLine();
			t[i]=new Team(NextInt(), NextInt());
		}
		Arrays.sort(t);
		int ti=t[k].t, p=t[k].p;

		for(int i=0; i<n; i++)
			if(t[i].t==ti&&t[i].p==p)ret++;

		System.out.print(ret);
        closeInput();
	}

	private class Team implements Comparable<Team>
	{
		int p,t;
		Team(int p, int t)
		{
			this.p=p;
			this.t=t;
		}

		public int compareTo(Team d)
		{
			return 10000*(d.p-p)+t-d.t;
		}
	}

}


import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class C113A{
    static BufferedReader br;
    public static void main(String args[])throws Exception{
        br=new BufferedReader(new InputStreamReader(System.in));
        int nm[]=toIntArray();
        int n=nm[0];
        int k=nm[1];
        Pai p[]=new Pai[n];
        for(int i=0;i<n;i++){
            nm=toIntArray();
            p[i]=new Pai(nm[0],nm[1]);
        }
        Arrays.sort(p);
        int count=0;
        for(int i=0;i<n;i++){
            if(p[k-1].first==p[i].first && p[k-1].second==p[i].second){
                count++;
            }
        }
        System.out.println(count);

    }

    /****************************************************************/
    public static int[] toIntArray()throws Exception{
       String str[]=br.readLine().split(" ");
       int k[]=new int[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Integer.parseInt(str[i]);
       }
       return k;
    }
    public static int toInt()throws Exception{
       return Integer.parseInt(br.readLine());
    }
    public static long[] toLongArray()throws Exception{
       String str[]=br.readLine().split(" ");
       long k[]=new long[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Long.parseLong(str[i]);
       }
       return k;
    }
    public static long toLong()throws Exception{
       return Long.parseLong(br.readLine());
    }
    public static double[] toDoubleArray()throws Exception{
       String str[]=br.readLine().split(" ");
       double k[]=new double[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Double.parseDouble(str[i]);
       }
       return k;
    }
    public static double toDouble()throws Exception{
       return Double.parseDouble(br.readLine());
    }
    public static String toStr()throws Exception{
       return br.readLine();
    }
    public static String[] toStrArray()throws Exception{
       String str[]=br.readLine().split(" ");
       return str;
    }
    /****************************************************************/

}
class Pai implements Comparable<Pai> {

    int first;
    int second;

    public Pai(int f, int s) {
        first = f;
        second = s;
    }

    public int compareTo(Pai p) {
        int ret = 0;
        if (first < p.first) {
            ret = 1;

        } else if (first > p.first) {
            ret = -1;

        } else {
            if(second<p.second){
                ret=-1;
            }
            else if(second>p.second){
                ret=1;
            }
            else ret=0;
        }
        return ret;
    }
}


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

public class A {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;

    class Team implements Comparable<Team>{
        int ac;
        int penalty;

        public Team(int ac, int penalty) {
            this.ac = ac;
            this.penalty = penalty;
        }

        @Override
        public int compareTo(Team o) {
            if (ac != o.ac)
                return ac > o.ac ? -1 : 1;
            return (penalty == o.penalty) ? 0 : (penalty < o.penalty ? -1 : 1);
        }

    }

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

        Team[] a = new Team[n];
        for (int i = 0; i < n; i++)
            a[i] = new Team(nextInt(), nextInt());

        Arrays.sort(a);
        for (int i = 0; i < n;) {
            int j = i;
            while (j < n && a[j].compareTo(a[i]) == 0)
                j++;
            if (i <= k && k < j) {
                out.println(j - i);
                return;
            }
            i = j;
        }
    }

    void inp() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

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

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

    String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }

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

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

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


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

public class P166A {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        Point[] P = new Point[n];
        for(int i=0; i<n; i++)
            P[i] = new Point(in.nextInt(), in.nextInt());
        Arrays.sort(P, new Comparator<Point>() {
            public int compare(Point A, Point B) {
                if(A.x != B.x) return B.x-A.x;
                return A.y - B.y;
            }
        });
        int cnt = 0;
        Point ans = P[k-1];
        for(int i=0; i<n; i++) {
            if(P[i].x == ans.x && P[i].y==ans.y)
                cnt++;
        }
        System.out.println(cnt);
    }
}


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

public class Main {

	public static void main(String[] argv) {
		new Main().run();
	}

	void run() {

		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		try {
			solve();
		} finally {
			out.close();
		}
	}

	PrintWriter out;
	Scanner in;

	class Pair {
		int x;
		int y;

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

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

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

	void solve() {
		int n = in.nextInt();
		int k = in.nextInt();
		Pair[] a = new Pair[n];
		for (int i = 0; i < n; i++) {
			a[i] = new Pair(in.nextInt(), in.nextInt());
		}
		Arrays.sort(a, new Comparator<Pair>() {

			@Override
			public int compare(Pair p1, Pair p2) {
				if (p2.x != p1.x) {
					return p2.x - p1.x;
				}
				return p1.y - p2.y;
			}
		});
		int cnt = 1;
		int ans = 0;
		int[] res = new int[n];
		res[0] = 1;
		for (int i = 1; i < n; i++) {
			if (!(a[i].x == a[i - 1].x && a[i].y == a[i - 1].y)) {
				cnt++;
			}
			res[i] = cnt;
			//out.println(a[i] + " * " + cnt);
		}
		int el = res[k - 1];
		for (int i = 0; i < n; i++) {
			if (res[i] == el) {
				ans++;
			}
		}
		out.println(ans);

	}
}


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 A {

    static StreamTokenizer st;
    static PrintWriter pw;
    static class Sort implements Comparable<Sort> {
        int x,y;
        public int compareTo(Sort arg0) {
            if (this.x==arg0.x)
                return this.y-arg0.y;
            return -(this.x-arg0.x);
        }
    }
    public static void main(String[] args) throws IOException{
        st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int k = nextInt();
        Sort[]a = new Sort[n+1];
        for (int i = 1; i <= n; i++) {
            a[i] = new Sort();
            a[i].x = nextInt();
            a[i].y = nextInt();
        }
        Arrays.sort(a,1, n+1);
//      for (int i = 1; i <= n; i++) {
//          System.out.println(a[i].x+" "+a[i].y);
//      }
//      int plase = 1;
//      if (k==1) {
//          int ans = 0;
//          for (int j = 1; j <= n; j++) {
//              if (a[j].x==a[1].x && a[j].y ==a[1].y) {
//                  ans++;
//              }
//          }
//          System.out.println(ans);
//          return;
//      }
//      for (int i = 2; i <= n; i++) {
//          if (a[i].x==a[i-1].x && a[i].y==a[i-1].y) {
//
//          }
//          else {
//              plase++;
//              if (plase==k) {
//                  int ans = 0;
//                  for (int j = 1; j <= n; j++) {
//                      if (a[j].x==a[i].x && a[j].y ==a[i].y) {
//                          ans++;
//                      }
//                  }
//                  System.out.println(ans);
//                  return;
//              }
//          }
//      }
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (a[i].x==a[k].x && a[i].y==a[k].y)
                ans++;
        }
        System.out.println(ans);
        pw.close();
    }
    private static int nextInt() throws IOException{
        st.nextToken();
        return (int) st.nval;
    }
}


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

public class A {

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int n  = scan.nextInt();
		int k = scan.nextInt()-1;
		team[] t = new team[n];
		for(int i = 0 ;i  < n ; i++)
			t[i] = new team(scan.nextInt(), scan.nextInt());
		Arrays.sort(t);
		int a =0;
		int b = 0;
		while(k+a < t.length-1 && t[k+a+1].compareTo(t[k]) == 0)
			a++;
		while(k-b > 0 && t[k-b-1].compareTo(t[k]) == 0)
			b++;
		System.out.println(a+b+1);
	}

}
class team implements Comparable<team>
{
	int p;
	int t;
	public team(int pp , int tt)
	{
		p = pp;
		t= tt;
	}
	@Override
	public String toString()
	{
		return p+" "+t;
	}
	@Override
	public int compareTo(team e)
	{
		int a = e.p-p;
		if(a == 0)
		{
			return  t-e.t;
		}else
			return a;
	}
}


import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int k = input.nextInt() - 1 ;
        int a[][] = new int[n][2];
        for (int i = 0;i <n; i++) {
            a[i][0]=input.nextInt();
            a[i][1]=input.nextInt();
        }
        for (int i = 0; i<n; i++) {
            for (int j=i+1; j<n; j++) {
                if (a[i][0]<a[j][0]) {
                    int x=a[i][0];
                    int y=a[i][1];
                    a[i][0]=a[j][0];
                    a[i][1]=a[j][1];
                    a[j][0]=x;
                    a[j][1]=y;

                }
            }
        }
        for (int i = 0; i<n; i++) {
            for (int j=i+1; j<n; j++) {
                if ((a[i][1]>a[j][1])&&(a[i][0]==a[j][0])) {
                    int x=a[i][0];
                    int y=a[i][1];
                    a[i][0]=a[j][0];
                    a[i][1]=a[j][1];
                    a[j][0]=x;
                    a[j][1]=y;

                }
            }
        }
        int x = a[k][0];
        int y = a[k][1];
        int s = 0;
        for (int i = 0; i<n; i++) {
            if ((a[i][0]==x)&&(a[i][1]==y)) {
                s++;
            }
        }
        System.out.println(s);
    }
}


//package codeforces;

import java.util.*;

public class Main {
    class team implements Comparable<team>{
        int pro,time;

        public int compareTo(team oth) {
            if(pro>oth.pro)
                return -1;
            if(pro==oth.pro&&time<oth.time)
                return -1;
            // TODO Auto-generated method stub
            return 1;
        }

    }
    Scanner scan=new Scanner(System.in);
    void run(){
        int n=scan.nextInt();
        int k=scan.nextInt()-1;
        team tm[]=new team[n];
        for(int i=0;i<n;i++){
            tm[i]=new team();
            tm[i].pro=scan.nextInt();
            tm[i].time=scan.nextInt();
        }
        Arrays.sort(tm);
        int sum=0;

        for(int i=k;i>=0;i--)
            if(tm[i].pro==tm[k].pro&&tm[i].time==tm[k].time)
                sum++;
        for(int i=k;i<n;i++)
            if(tm[i].pro==tm[k].pro&&tm[i].time==tm[k].time)
                sum++;
        System.out.println(sum-1);
    }
    public static void main(String args[]) {

        new Main().run();
    }

}


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

public class Main {

    private void solve() {
        int n = in.nextInt();
        int k = in.nextInt();
        final int[] p = new int[n];
        final int[] t = new int[n];
        for(int i =0 ; i < n; ++i) {
            p[i] = in.nextInt();
            t[i] = in.nextInt();
        }
        Integer[] ord = new Integer[n];
        for(int i = 0; i < n; ++i)
            ord[i] = i;
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < n - 1; ++j) {
                if (Less(ord[j], ord[j + 1], p, t)) {
                    Integer tx = ord[j];
                    ord[j] = ord[j + 1];
                    ord[j + 1] = tx;
                }
            }
        }

        for(int i = 0, j = 0; i < n; i = j) {
            for(j = i; j < n && p[ord[i]] == p[ord[j]] && t[ord[i]] == t[ord[j]]; ++j) ;
            int first = i+1;
            int second = j;
            if (first <= k && k <= second) {
                out.print(j - i);
                return ;
            }
        }
        out.print(0);
    }
    private boolean Less(Integer i, Integer j, int[] p, int[] t) {
        return p[i] < p[j] || p[i] == p[j] && t[i] > t[j];
    }
    private void run() {
        try {
            in = new FastScanner();
            out = new PrintWriter(new OutputStreamWriter(System.out));
            solve();
            out.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
    FastScanner in;
    PrintWriter out;
    class FastScanner {
        public BufferedReader reader;
        private StringTokenizer tokenizer;
        public FastScanner(String file) {
            try {
                reader = new BufferedReader(new FileReader(new File(file)));
                tokenizer = null;
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            try {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        public String nextToken() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(nextToken());
        }
        long nextLong() {
            return Long.parseLong(nextToken());
        }
    }
}


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.Comparator;
import java.util.Locale;
import java.util.StringTokenizer;

public class A {

	private class Pair {
		public final int prob;
		public final int time;

		public Pair(int prob, int time) {
			this.prob = prob;
			this.time = time;
		}
	}

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

		Pair[] p = new Pair[n];
		for (int i = 0; i < n; i++) {
			p[i] = new Pair(nextInt(), nextInt());
		}

		Arrays.sort(p, new Comparator<Pair>() {
			@Override
			public int compare(Pair o1, Pair o2) {
				if (o1.prob == o2.prob) {
					return o1.time - o2.time;
				}
				return o2.prob - o1.prob;
			}
		});

		int time = p[k - 1].time;
		int prob = p[k - 1].prob;
		int res = 0;
		for (int i = 0; i < n; i++) {
			if (p[i].time == time && p[i].prob == prob) {
				res++;
			}
		}
		println(res);
	}

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

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

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

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

	private void print(Object o) {
		writer.print(o);
	}

	private void println(Object o) {
		writer.println(o);
	}

	private void printf(String format, Object... o) {
		writer.printf(format, o);
	}

	public static void main(String[] args) {
		long time = System.currentTimeMillis();
		Locale.setDefault(Locale.US);
		new A().run();
		System.err.printf("%.3f\n", 1e-3 * (System.currentTimeMillis() - time));
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	private void run() {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(13);
		}
	}
}


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

public class Round113_A {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt() - 1;
        Obe[] a = new Obe[n];
        for (int i = 0; i < n; i++)
            a[i] = new Obe(in.nextInt(), in.nextInt());

        Arrays.sort(a);
        int c = 0;

        int p = 0, d = 0;
        if (k > -1 && k < n) {
            c = 1;
            p = a[k].p;
            d = a[k].d;
        } else {
            System.out.println(c);
            return;
        }
        for (int i = k + 1; i < n; i++) {
            if (a[i].p == p && a[i].d == d)
                c++;
        }
        for (int i = k - 1; i > -1; i--) {
            if (a[i].p == p && a[i].d == d)
                c++;
        }
        System.out.println(c);
    }

}

class Obe implements Comparable<Obe> {

    int p, d;

    public Obe(int pe, int de) {
        p = pe;
        d = de;
    }

    @Override
    public int compareTo(Obe o) {
        int x = new Integer(o.p).compareTo(this.p);
        if (x != 0)
            return x;
        return new Integer(this.d).compareTo(o.d);
    }

}


import java.util.List;
import java.util.Scanner;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.io.InputStream;

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

class TaskA {
     class Pair{
		public int a;
		public int b;
		public Pair(int a, int b) {
			// TODO Auto-generated constructor stub
			this.a = a;
			this.b = b;
		}
	}

    public void solve(int testNumber, Scanner in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();  --k;
        ArrayList<Pair> list = new ArrayList<Pair>();
		for (int i = 1; i <= n; ++i){
            int num = in.nextInt();
            int pen = in.nextInt();
			Pair t = new Pair(num, pen);
		    list.add(t);
        }
        Collections.sort(list, new Comparator<Pair>(){
				public int compare(Pair o1, Pair o2){
					if (o1.a != o2.a){
						return (o2.a - o1.a);
					}
					return (o1.b - o2.b);
				}
		});

        int res = 1;
        Pair compare = list.get(k);
        int i = k - 1;
        while (i >= 0){
            Pair t = list.get(i);
            if (t.a == compare.a && t.b == compare.b){
                --i;
                ++res;
                continue;
            }else{
                break;
            }
        }
       i = k + 1;
        while (i < list.size()){
            Pair t = list.get(i);
            if (t.a == compare.a && t.b == compare.b){
                ++res; ++i;
                continue;
            }else{
                break;
            }
        }
        out.println(res);
       return;
    }
}


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

public class P113A {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = System.out;
        //CODING TAIM

        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Team> l = new ArrayList<Team>();
        for (int i = 0; i < n; i++) {
            l.add(new Team(sc.nextInt(), sc.nextInt()));
        }
        Collections.sort(l, new Comparator<Team>() {
                public int compare(Team a, Team b) {
                    if (a.s == b.s)
                        return a.t - b.t;
                    return b.s - a.s;
                }
                });
        int f = k - 1;
        int la = k - 1;
        Team p = l.get(k - 1);
        while (la < n && l.get(la).s == p.s && l.get(la).t == p.t) la++;
        while ( f >= 0 && l.get(f).s == p.s && l.get(f).t == p.t) f--;
        out.println(la - f - 1);
    }

  static   class Team {
        int s;
        int t;
        public Team(int a, int b) { s = a; t = b; }
    }

}


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

public class A
{
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = null;

    private void solve() throws IOException
    {
        int n = nextInt();
        int k = nextInt();
        int p[] = new int[n];
        int t[] = new int[n];
        for(int i = 0; i < n; i++)
        {
            p[i] = nextInt();
            t[i] = nextInt();
        }

        for(int i = 0; i < n; i++)
        {
            for(int j = i + 1; j < n; j++)
            {
                if(p[i] < p[j] || (p[i] == p[j] && t[i] > t[j]))
                {
                    int tmp = p[i];
                    p[i] = p[j];
                    p[j] = tmp;
                    tmp = t[i];
                    t[i] = t[j];
                    t[j] = tmp;
                }
            }

        }

        int pN = p[k - 1];
        int tN = t[k - 1];
        int counter = 0;
        for(int i = 0; i < n; i++)
        {
            if(p[i] == pN && t[i] == tN)
            {
                counter++;
            }

        }

        System.out.println(counter);
    }

    String nextToken() throws IOException
    {
        if (st == null || !st.hasMoreTokens())
        {
            st = new StringTokenizer(bf.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());
    }

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

}


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

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

class TaskA {

    class Team implements Comparable<Team> {
        int solved = 0;
        int penalty = 0;

        Team(int solved, int penalty) {
            this.solved = solved;
            this.penalty = penalty;
        }

        public int compareTo(Team o) {
            return this.solved == o.solved ? this.penalty - o.penalty : -(this.solved - o.solved);
        }

        public boolean equals(Object obj) {
            if (obj instanceof Team) {
                Team o = (Team) obj;
                return ((this.solved == o.solved) && (this.penalty == o.penalty));
            }
            return false;
        }
    }

    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        Team[] teams = new Team[n];
        for (int i = 0; i < n; i++)
            teams[i] = new Team(in.nextInt(), in.nextInt());
        Arrays.sort(teams);

        int[] top = new int[n];
        int[] map = new int[n];
        int cur = -1;
        for (int i = 0; i < n; i++) {
            if (i == 0 || !teams[i].equals(teams[i - 1])) cur = i;
            top[cur]++;
            map[i] = cur;
        }
        out.println(top[map[k - 1]]);
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

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

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

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

    }

class OutputWriter {
    private final PrintWriter writer;

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

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

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            writer.print(objects[i]);
        }
    }

    public void println(Object... objects) {
        print(objects);
        writer.println();
    }

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


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

public class Solution {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), k = in.nextInt();
        int x[] = new int[n];
        for (int i = 0; i < n; i++) {
            int p = in.nextInt(), t = in.nextInt();
            x[i] = (50 - p) * 100 + t;
        }
        Arrays.sort(x);
        int cnt = 0;
        for (int q: x)
            if (q == x[k - 1]) cnt++;
        System.out.println(cnt);
    }

}


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

public class Solution {
    static class Team implements Comparable<Team> {
        int pr;
        int time;
        int id;

        public Team(int P, int T, int I) {
            pr = P;
            time = T;
            id = I;
        }

        @Override
        public int compareTo(Team t) {
            return pr != t.pr ? t.pr - pr : time != t.time ? time - t.time : id - t.id;
        }

    }

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

        StringTokenizer st = new StringTokenizer(in.readLine());
        int n = Integer.parseInt(st.nextToken());

        int k = Integer.parseInt(st.nextToken());

        Team[] a = new Team[n];
        int[] c = new int[n + 1];

        for (int i = 0; i < n; i++) {
            st = new StringTokenizer(in.readLine());
            int p = Integer.parseInt(st.nextToken());
            int t = Integer.parseInt(st.nextToken());

            a[i] = new Team(p, t, i);
        }

        Arrays.sort(a);
        int prev = 1;
        c[1]++;

        for (int i = 1; i < n; i++) {
            if (a[i].pr == a[i - 1].pr && a[i].time == a[i - 1].time)
                for (int j = i + 1; j >= prev; j--)
                    c[j] = i + 2 - prev;
            else {
                prev = i + 1;
                c[prev] = 1;
            }
        }

        out.println(c[k]);
        out.close();
    }
}


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

public class Teams {
    BufferedReader in;
    PrintWriter out;
    StringTokenizer st;
    Random rnd;

    class Pair implements Comparable<Pair> {
        int a, b;

        public Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {
            if(a != p.a) {
                return -(a - p.a);
            }

            return (b - p.b);
        }
    }

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

        Pair[] ps = new Pair[n];

        for(int i = 0; i < n; i++)
            ps[i] = new Pair(nextInt(), nextInt());

        Arrays.sort(ps);

        int curPlace = 1, res = 0;

        int[] places = new int[n];

        for(int i = 0; i < n; i++) {
            if(i - 1 >= 0 && ps[i].compareTo(ps[i - 1]) != 0)
                ++curPlace;

            places[i] = curPlace;
        }

        for(int i = 0; i < n; i++) {
            if(places[i] == places[k - 1])
                ++res;
        }

        out.println(res);
    }

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

    public void run() {
        try {
            final String className = this.getClass().getName().toLowerCase();

            try {
                in = new BufferedReader(new FileReader(className + ".in"));
                out = new PrintWriter(new FileWriter(className + ".out"));
            } catch (FileNotFoundException e) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            }

            rnd = new Random();

            solve();

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

    String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String line = in.readLine();

            if (line == null)
                return null;

            st = new StringTokenizer(line);
        }

        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());
    }
}


import sun.reflect.generics.tree.Tree;

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

public class A2 {
	static Scanner in; static int next() throws Exception {return in.nextInt();};
//	static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}
//	static BufferedReader in;
	static PrintWriter out;

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

        int n = next(), k = next()-1;
        int x[] = new int[n];
        for (int i = 0;i < n;i++) x[i] = (100-next())*100+next();
        Arrays.sort(x);
        int res = 0, t = x[k];
        for (int i = 0;i < n;i++) if (t == x[i]) res++;

        out.println(res);

        out.println();
		out.close();
	}
}


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

public class A113 {

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

    public void run() {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        Team[] teams = new Team[n];
        for (int i = 0; i < teams.length; i++) {
            teams[i] = new Team(in.nextInt(), in.nextInt());
        }
        Arrays.sort(teams);
        int counter = 1;
        int index = k-2;
        while (index >= 0 && teams[index].p == teams[k-1].p && teams[index].t == teams[k-1].t) {
            index--;
            counter++;
        }
        index = k;
        while (index < n && teams[index].p == teams[k-1].p && teams[index].t == teams[k-1].t) {
            index++;
            counter++;
        }
        System.out.println(counter);
    }

    private class Team implements Comparable<Team> {
        int p;
        int t;

        public Team(int pp, int tt) {
            p = pp; t = tt;
        }

        @Override
        public int compareTo(Team o) {
            if (o.p - this.p == 0)
                return this.t - o.t;
            return o.p - this.p;
        }
    }
}


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

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

class TaskA {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
        int n=in.nextInt(),k=in.nextInt()-1,i;
        scores a[]=new scores[n];
        for(i=0;i<n;i++)
            a[i]=new scores(in.nextInt(),in.nextInt());
        Arrays.sort(a);

        int c=1;
        for(i=k-1;i>=0;i--)
        {
            if(a[i].p==a[k].p&&a[i].t==a[k].t)
                c++;
            else break;
        }
        for(i=k+1;i<n;i++)
        {
            if(a[i].p==a[k].p&&a[i].t==a[k].t)
                c++;
            else break;
        }
        out.println(c);

	}
    class scores implements Comparable<scores>
    {
        int p,t;
        public scores(int p,int t)
        {
            this.p=p;
            this.t=t;
        }
        public int compareTo(scores a)
        {
            if(a.p>this.p)
                return 1;
            if(a.p==this.p&&a.t<this.t)
                return 1;
            return -1;
        }
    }
}


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

public class P166A
{
	public static void main(String[] args)
	{
		Scanner myScanner = new Scanner(System.in);
		int n = myScanner.nextInt();
		int k = myScanner.nextInt();
		Team[] queue = new Team[n];
		for (int i = 0; i < n; i++)
		{
			queue[i] = new Team(myScanner.nextInt(), myScanner.nextInt());
		}
		Arrays.sort(queue);

		int counter = 0;
		int i = 0;
		int p = -1;
		int t = -1;
		for (; i < k; i++)
		{
			if (p == queue[i].problems && t == queue[i].penalty)
				counter++;
			else
			{
				p = queue[i].problems;
				t = queue[i].penalty;
				counter = 1;
			}
		}
		for (; i < n; i++)
		{
			if (p == queue[i].problems && t == queue[i].penalty)
				counter++;
			else
				break;
		}
		System.out.println(counter);
	}

	static class Team implements Comparable<Team>
	{
		int problems;
		int penalty;

		public Team(int problems, int penalty)
		{
			this.problems = problems;
			this.penalty = penalty;
		}

		public int compareTo(Team t)
		{
			if (problems > t.problems) return -1;
			else if (problems < t.problems) return 1;
			else if (penalty > t.penalty) return 1;
			else if (penalty < t.penalty) return -1;
			else return 0;
		}
	}
}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class A {

    private void solve() throws IOException {
        int n = nextInt();
        int k = nextInt();
        Point[] p = new Point[n];
        for (int i = 0; i < n; i++)
            p[i] = new Point(nextInt(), nextInt());
        Arrays.sort(p, new Comparator<Point>() {

            @Override
            public int compare(Point o1, Point o2) {
                if (o1.x == o2.x) return o1.y - o2.y;
                return o2.x - o1.x;
            }
        });

        Point cur = p[k - 1];
        int res = 0;
        for (int i = 0; i < p.length; i++) {
            if (p[i].x == cur.x && p[i].y == cur.y) res++;
        }
        pl(res);
    }

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

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        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);
        }
    }

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

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

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

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

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

    void p(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.flush();
            writer.print(objects[i]);
            writer.flush();
        }
    }

    void pl(Object... objects) {
        p(objects);
        writer.flush();
        writer.println();
        writer.flush();
    }

    int cc;

    void pf() {
        writer.printf("Case #%d: ", ++cc);
        writer.flush();
    }

}


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

public class A {

	static class team implements Comparable<team>
	{
		int problems;
		int penalty;
		public team(int problems,int penalty)
		{
			this.penalty=penalty;
			this.problems=problems;
		}
		public int compareTo(team a) {
			if (a.problems==this.problems)
				return this.penalty - a.penalty;
			return a.problems - this.problems;
		}

		public boolean igual(team a)
		{
			if (this.problems!=a.problems)
				return false;
			return (this.penalty==a.penalty);
		}
	}

	static class Scanner
	{
		BufferedReader rd;
		StringTokenizer tk;
		public Scanner() throws IOException
		{
			rd=new BufferedReader(new InputStreamReader(System.in));
			tk=new StringTokenizer(rd.readLine());
		}
		public String next() throws IOException
		{
			if (!tk.hasMoreTokens())
			{
				tk=new StringTokenizer(rd.readLine());
				return tk.nextToken();
			}
			return tk.nextToken();
		}
		public int nextInt() throws NumberFormatException, IOException
		{
			return Integer.valueOf(this.next());
		}
	}

	static team[] array=new team[100];
	static int N,K;

	public static void main(String args[]) throws IOException
	{
		Scanner sc=new Scanner();
		N=sc.nextInt();
		K=sc.nextInt();
		for(int i=0;i<N;i++)
		{
			array[i]=new team(sc.nextInt(),sc.nextInt());
		}
		Arrays.sort(array,0,N);
		/*
		for(int i=0;i<N;i++)
			System.out.println(array[i].problems);*/

		int shared=0;
		for(int i=K-1;i>=0 && array[K-1].igual(array[i]);i--,shared++);
		for(int i=K;i<N && array[K-1].igual(array[i]);i++,shared++);
		System.out.println(shared);
	}

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;

public class Solution {

	class Q implements Comparable<Q> {
		int p, t;
		Q(int q, int w) {
			p = q; t = w;
		}
		@Override
		public int compareTo(Q arg0) {
			if (p == arg0.p) return t - arg0.t;
			return arg0.p - p;
		}
	}

	void solve() throws Exception {
		int n = nextInt();
		int k = nextInt() - 1;
		Q[] a = new Q[n];
		for (int i = 0; i < n; i++) a[i] = new Q(nextInt(), nextInt());
		Arrays.sort(a);
		int ans = 1;
		for (int i = k - 1; i >= 0; i--) if (a[i].compareTo(a[k]) == 0) ans++; else break;
		for (int i = k + 1; i < n; i++) if (a[i].compareTo(a[k]) == 0) ans++; else break;
		out.println(ans);
	}

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

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

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

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

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

}


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

public class A {

	class Team implements Comparable<Team>{
		int p, t;
		public Team(int p, int t) {
			this.p = p;
			this.t = t;
		}
		public int compareTo(Team other) {
			if (this.p != other.p) return other.p - this.p;
			return this.t - other.t;
		}
	}

	public void solve() throws IOException {
		int n = nextInt();
		int K = nextInt() - 1;
		Team[] team = new Team[n];
		for (int i = 0; i < n; i++)
			team[i] = new Team(nextInt(), nextInt());

		Arrays.sort(team);
		int ans = -1;
		int pre = 0;
		for (int i = 1; i < n; i++)
			if (team[i].compareTo(team[i - 1]) != 0) {
				if (K >= pre && K < i) {
					ans = i - pre;
					break;
				}
				pre = i;
			}
		if (ans == -1) ans = n - pre;
		writer.println(ans);
	}

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

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() {
		try {
			long tbegin = System.currentTimeMillis();
			reader = new BufferedReader(new InputStreamReader(System.in));
			//reader = new BufferedReader(new InputStreamReader(new FileInputStream("test.inp")));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			//writer = new PrintWriter(new FileOutputStream("test.out"));
			solve();
			//reader.close();
			//System.out.println(System.currentTimeMillis() - tbegin + "ms");
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	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();
	}

}


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

public class cf166a {
	private static boolean[][] matrix;
	private static int n;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// long l = sc.nextLong();
		// int i = sc.nextInt();
		// String input = sc.nextLine();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] p = new int[n];
		int[] t = new int[n];
		int[] score = new int[n];
		for(int i=0;i<n;i++){
			p[i] = sc.nextInt();
			t[i] = sc.nextInt();
			score[i] = p[i] * 100 + (50 - t[i]);
		}
		boolean[] called = new boolean[n];
		int x = 0;
		boolean check = false;
		while(true){
			int max = 0;
			int y = 0;
			for(int i=0;i<n;i++){
				if(called[i]==false&&score[i]>max){max=score[i];}
			}
			for(int i=0;i<n;i++){
				if(max==score[i]){
					called[i] = true;
					x++;
					y++;
					if(x==k){check=true;}
				}
			}
			if(check){
				System.out.println(y);
				break;
			}
		}
	}
}


import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

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

class TaskA {
	public void solve(int testNumber, InputReader in, OutputWriter out) {
		int count = in.readInt();
		int place = in.readInt() - 1;
		final int[] points = new int[count];
		final int[] time = new int[count];
		IOUtils.readIntArrays(in, points, time);
		Comparator<Integer> comparator = new Comparator<Integer>() {
			public int compare(Integer o1, Integer o2) {
				if (points[o1] != points[o2])
					return points[o2] - points[o1];
				return time[o1] - time[o2];
			}
		};
		Integer[] order = ArrayUtils.order(count, comparator);
		int answer = 0;
		for (int i = 0; i < count; i++) {
			if (comparator.compare(order[place], order[i]) == 0)
				answer++;
		}
		out.printLine(answer);
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;

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

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

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

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

	}

class OutputWriter {
	private final PrintWriter writer;

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

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

	public void print(Object...objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(Object...objects) {
		print(objects);
		writer.println();
	}

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

	}

class IOUtils {

	public static void readIntArrays(InputReader in, int[]... arrays) {
		for (int i = 0; i < arrays[0].length; i++) {
			for (int j = 0; j < arrays.length; j++)
				arrays[j][i] = in.readInt();
		}
	}

	}

class ArrayUtils {
	public static Integer[] generateOrder(int size) {
		Integer[] order = new Integer[size];
		for (int i = 0; i < size; i++)
			order[i] = i;
		return order;
	}

	public static Integer[] order(int size, Comparator<Integer> comparator) {
		Integer[] order = generateOrder(size);
		Arrays.sort(order, comparator);
		return order;
	}

	}


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

public class Main {

    public static void main(String[] args) throws Exception{
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt() - 1;
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            int p = scan.nextInt();
            int t = scan.nextInt();
            arr[i] = -p * 10000 + t;
        }
        Arrays.sort(arr);
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (arr[i] == arr[k]) {
                count++;
            }
        }
        System.out.println(count);
    }
}


//package round113;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;

public class A {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni(), k = ni();
		int[][] d = new int[n][2];
		for(int i = 0;i < n;i++){
			d[i][0] = ni();
			d[i][1] = ni();
		}

		Arrays.sort(d, new Comparator<int[]>() {
			public int compare(int[] a, int[] b) {
				if(a[0] - b[0] != 0)return -(a[0] - b[0]);
				return a[1] - b[1];
			}
		});

		int b;
		for(b = k-1;b >= 0 && d[k-1][0] == d[b][0] && d[k-1][1] == d[b][1];b--);
		b++;
		int a;
		for(a = k-1;a < n && d[k-1][0] == d[a][0] && d[k-1][1] == d[a][1];a++);
		a--;
		out.println(a-b+1);
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

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

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


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

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

class TaskA {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
        int N = in.nextInt();
        int k = in.nextInt();
        Team[] t = new Team[N];
        for (int i=0; i<N; i++) t[i] = new Team(in.nextInt(), in.nextInt());
        Arrays.sort(t);
        int p_k = t[k-1].p, t_k = t[k-1].t;
        int count = 0;
        for (int i=0; i<N; i++) if (t[i].p==p_k && t[i].t ==t_k) count++;
        out.println(count);
	}
}

class Team implements Comparable<Team>{
    int p, t;
    Team(int a, int b) { p=a; t=b;}
    public int compareTo(Team g) {
        if (p < g.p) return 1;
        if (p > g.p) return -1;
        if (t < g.t) return -1;
        if (t > g.t) return 1;
        return 0;
    }

}


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

public class Solver {

    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws NumberFormatException, IOException {
        Solver solver = new Solver();
        solver.open();
        solver.solve();
        solver.close();
    }

    public void open() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

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

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

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

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

    public class result implements Comparable{
        public int t = 0;
        public int p = 0;

        public result(int p,int t){
            this.t = t;
            this.p = p;
        }

        @Override
        public int compareTo(Object o) {
            result r = (result)o;
            int out = r.p-p;
            if (out==0) out = t-r.t;
            return out;
        }

    }

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

        result[] table = new result[n];

        for (int i=0;i<n;i++){
            int p = nextInt();
            int t = nextInt();

            table[i] = new result(p,t);
        }

        Arrays.sort(table);

        int result = 1;
        k--;

        for (int i=k-1;i>=0 && table[i].p==table[k].p && table[i].t==table[k].t;i--){
            result++;
        }
        for (int i=k+1;i<n && table[i].p==table[k].p && table[i].t==table[k].t;i++){
            result++;
        }
        out.println(result);
    }

    public void close() {
        out.flush();
        out.close();
    }

}


import java.util.Arrays;

/**
 * @author piuspratik (Piyush Das)
 */
public class TaskA {

    class Contest implements Comparable<Contest>

    {
        int problems;
        int penalty;

        Contest (int problems, int penalty) {
            this.problems = problems;
            this.penalty = penalty;
        }

        public int compareTo(Contest contest) {
            if(problems != contest.problems) return contest.problems - problems;
            return penalty - contest.penalty;

        }
    }

    void run(){
        int n = nextInt(), k = nextInt();
        Contest[] c = new Contest[n];
        for(int i = 0; i < n; i++) {
            c[i] = new Contest(nextInt(), nextInt());
        }

        Arrays.sort(c);
        int cproblem = c[k - 1].problems, cpenalty = c[k - 1].penalty;

        int ans = 0;
        for(int i = 0; i < n; i++) {
            if(c[i].problems == cproblem && c[i].penalty == cpenalty) ans++;
        }

        System.out.println(ans);
    }

    int nextInt(){
        try{
            int c = System.in.read();
            if(c == -1) return c;
            while(c != '-' && (c < '0' || '9' < c)){
                c = System.in.read();
                if(c == -1) return c;
            }
            if(c == '-') return -nextInt();
            int res = 0;
            do{
                res *= 10;
                res += c - '0';
                c = System.in.read();
            }while('0' <= c && c <= '9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }

    long nextLong(){
        try{
            int c = System.in.read();
            if(c == -1) return -1;
            while(c != '-' && (c < '0' || '9' < c)){
                c = System.in.read();
                if(c == -1) return -1;
            }
            if(c == '-') return -nextLong();
            long res = 0;
            do{
                res *= 10;
                res += c-'0';
                c = System.in.read();
            }while('0' <= c && c <= '9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }

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

    String next(){
        try{
            StringBuilder res = new StringBuilder("");
            int c = System.in.read();
            while(Character.isWhitespace(c))
                c = System.in.read();
            do{
                res.append((char)c);
            }while(!Character.isWhitespace(c=System.in.read()));
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }

    String nextLine(){
        try{
            StringBuilder res = new StringBuilder("");
            int c = System.in.read();
            while(c == '\r' || c == '\n')
                c = System.in.read();
            do{
                res.append((char)c);
                c = System.in.read();
            }while(c != '\r' && c != '\n');
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }

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

}


//package fourninetysixDiv3;
import java.util.HashMap;
import java.util.Scanner;
public class Median_Segments_general {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int m = s.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = s.nextInt();
		}
		System.out.println(func(n, m, arr)-func(n, m+1, arr));
	}
	public static long func(int n,int m,int[] arr) {
		HashMap<Long, Integer> map = new HashMap<>();
		map.put((long) 0, 1);
		long sum = 0;
		long res = 0;
		long add=0;
		for(int i=0;i<n;i++) {
			if(arr[i]<m) {
				sum--;
				if(map.containsKey(sum)) {
					add-=map.get(sum);
				}
			}
			else {
				if(map.containsKey(sum)) {
					add+=map.get(sum);
				}
				sum++;
			}
			res+=add;
			if(map.containsKey(sum)) {
				map.put(sum, map.get(sum)+1);
			}
			else {
				map.put(sum,1);
			}
		}
		return res;
	}
}

1005_E1. Median on Segments (Permutations Edition)


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
    static BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer tok;
    static boolean hasNext()
    {
        while(tok==null||!tok.hasMoreTokens())
            try{
                tok=new StringTokenizer(in.readLine());
            }
            catch(Exception e){
                return false;
            }
        return true;
    }
    static String next()
    {
        hasNext();
        return tok.nextToken();
    }
    static long nextLong()
    {
        return Long.parseLong(next());
    }
    static int nextInt()
    {
        return Integer.parseInt(next());
    }
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) {
        Map<Integer,Integer> map = new HashMap();
        map.put(0,1);
        int n = nextInt();
        int m = nextInt();
        int index = -1;
        int a[] = new int[n];
        for(int i=0;i<n;i++){
            a[i]=nextInt();
            if(a[i]==m)
                index=i;
        }
        int sum = 0;
        for(int i=0;i<index;i++){
            if (a[i]<m)
                sum--;
            else
                sum++;
            if (map.containsKey(sum)){
                map.put(sum,map.get(sum)+1);
            }else {
                map.put(sum,1);
            }
        }
        long ans = 0;
        for(int i=index;i<n;i++){
            if (a[i]<m)
                sum--;
            else if(a[i]>m)
                sum++;
            if (map.containsKey(sum))
                ans+=map.get(sum);
            if (map.containsKey(sum-1))
                ans+=map.get(sum-1);
        }
        out.print(ans);
        out.flush();
    }
}