source_code: 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;
  	}
  
  	}
  
  