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() !=... What is the time complexity of the previous code?