#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first)
    return a.first > b.first;
  else
    return a.second < b.second;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  pair<int, int> arr[n];
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    arr[i] = make_pair(x, y);
  }
  sort(arr, arr + n, cmp);
  pair<int, int> team = arr[k - 1];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == team) ans++;
  }
  cout << ans;
  return 0;
}
