#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
void debug(int n) { cout << "loop " << n << endl; }
struct nibbi {
  int u;
  int v;
  int w;
};
bitset<1000009 + 10> isp;
vector<int> primes;
void bitSieve() {
  for (int i = 3; i * i <= 1000009; i += 2) {
    if (isp[i] == false) {
      for (int j = i * i; j <= 1000009; j += i) {
        isp[j] = true;
      }
    }
  }
  primes.push_back(2);
  for (int i = 3; i <= 1000009; i += 2) {
    if (isp[i] == false) primes.push_back(i);
  }
}
int bigmod(long long a, long long p, long long m) {
  if (p == 0) return 1;
  if (p & 1) return ((a % m) * (bigmod(a, p - 1, m))) % m;
  long long tmp = bigmod(a, p / 2, m);
  return (tmp * tmp) % m;
}
bool cmp(const pair<int, int> &p1, const pair<int, int> &p2) {
  if (p1.first == p2.first) {
    return p1.second < p2.second;
  } else
    return p1.first > p2.first;
}
int main() {
  int n, k;
  cin >> n >> k;
  map<pair<int, int>, int> mp;
  vector<pair<int, int> > vp;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    vp.push_back({x, y});
    mp[{x, y}]++;
  }
  sort(vp.begin(), vp.end(), cmp);
  cout << mp[vp[k - 1]] << endl;
  return 0;
}
