#include <bits/stdc++.h>
using namespace std;
const int dx[] = {0, -1, 0, 1, -1, 1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};
const double EPS = 1e-9;
const long double PI = 3.1415926535897932384L;
const long long int INF = 9223372036854775807;
const int MOD = 1000000000 + 7;
const int MAX = 10000000 + 7;
vector<pair<int, int> > arr;
int N, k;
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first) return true;
  if (a.first == b.first and a.second < b.second) return true;
  return false;
}
int main() {
  cin >> N >> k;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    arr.push_back({a, b});
  }
  sort(arr.begin(), arr.end(), cmp);
  int s = arr[k - 1].first, p = arr[k - 1].second, cnt = 0;
  for (int i = 0; i < N; i++)
    if (arr[i].first == s and arr[i].second == p) cnt++;
  return cout << cnt << endl, 0;
}
