#include <bits/stdc++.h>
using namespace std;
inline void debug() {}
bool comp(pair<long long, long long>& a, pair<long long, long long>& b) {
  if (a.first > b.first)
    return true;
  else if (a.first == b.first && a.second < b.second)
    return true;
  else
    return false;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  pair<long long, long long> arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i].first >> arr[i].second;
  sort(arr, arr + n, comp);
  long long c = 1;
  long long st = k - 2;
  while (st >= 0 && (arr[st].first == arr[k - 1].first &&
                     arr[st].second == arr[k - 1].second)) {
    c++;
    st--;
  }
  st = k;
  while (st < n && (arr[st].first == arr[k - 1].first &&
                    arr[st].second == arr[k - 1].second)) {
    c++;
    st++;
  }
  cout << c;
}
