#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, arr[100000], trr[100000], cnt = 1;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    cin >> trr[i];
  }
  int temp, tem;
  for (int i = 0; i < (n - 1); i++) {
    for (int j = 0; j < n - i - 1; j++) {
      if (arr[j] > arr[j + 1] ||
          (arr[j] == arr[j + 1] && trr[j] < trr[j + 1])) {
        temp = arr[j];
        arr[j] = arr[j + 1];
        arr[j + 1] = temp;
        tem = trr[j];
        trr[j] = trr[j + 1];
        trr[j + 1] = tem;
      }
    }
  }
  int xx = lower_bound(arr, arr + n, arr[n - k]) - arr;
  int yy = upper_bound(arr, arr + n, arr[n - k]) - arr;
  for (int i = n - k;; i--) {
    if (i == 0) break;
    if (trr[i] == trr[i - 1] && arr[i] == arr[i - 1]) {
      cnt++;
    } else {
      break;
    }
  }
  for (int j = n - k;; j++) {
    if (trr[j] == trr[j + 1] && arr[j] == arr[j + 1]) {
      cnt++;
    } else {
      break;
    }
  }
  cout << cnt << endl;
}
