#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int arr[n][2];
  for (int i = 0; i < n; ++i) {
    cin >> arr[i][0] >> arr[i][1];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n - 1; ++j) {
      if (arr[j][0] < arr[j + 1][0]) {
        int temp = arr[j][0];
        int temp2 = arr[j][1];
        arr[j][0] = arr[j + 1][0];
        arr[j][1] = arr[j + 1][1];
        arr[j + 1][0] = temp;
        arr[j + 1][1] = temp2;
      } else if (arr[j][0] == arr[j + 1][0]) {
        if (arr[j][1] > arr[j + 1][1]) {
          int temp = arr[j][0];
          int temp2 = arr[j][1];
          arr[j][0] = arr[j + 1][0];
          arr[j][1] = arr[j + 1][1];
          arr[j + 1][0] = temp;
          arr[j + 1][1] = temp2;
        }
      }
    }
  }
  int a = arr[k - 1][0];
  int b = arr[k - 1][1];
  int f = 0;
  for (int i = 0; i < n; ++i) {
    if (arr[i][0] == a && arr[i][1] == b) {
      f++;
    }
  }
  cout << f;
  return 0;
}
