#include <bits/stdc++.h>
using namespace std;
struct point {
  int x;
  int y;
};
bool compare(point a, point b) {
  if (a.x == b.x)
    return (a.y < b.y);
  else
    return a.x > b.x;
}
int main() {
  int n, k, count = 0;
  cin >> n >> k;
  point arr[100];
  for (int i = 1; i <= n; i++) {
    int u, v;
    cin >> u >> v;
    arr[i].x = u;
    arr[i].y = v;
  }
  sort(arr + 1, arr + n + 1, compare);
  point temp = arr[k];
  for (int i = 1; i <= n; i++) {
    if (arr[i].x == temp.x && arr[i].y == temp.y) count++;
  }
  cout << count << endl;
  return 0;
}
