#include <bits/stdc++.h>
using namespace std;
double EPS = 1e-9;
int INF = 100005;
long long int mod = 1000000007;
long long TES = 1000007;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
bool compare(int a, int b) { return a < b; }
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first > b.first;
}
void solve() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> v;
  for (int(i) = (0); (i) < (n); ++(i)) {
    int x, y;
    cin >> x >> y;
    v.push_back(make_pair(x, y));
  }
  sort(v.begin(), v.end(), cmp);
  int a = v[k - 1].first, b = v[k - 1].second;
  int ans = 0;
  for (auto c : v) {
    if (a == c.first && b == c.second) ans++;
  }
  cout << ans << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  solve();
  return 0;
}
