#include<cstdio> #include<queue> #include<vector> using namespace std; struct cmp { bool operator()(int x, int y) { return x > y; } }; priority_queue<int, vector<int>, cmp>q; int main(int argc, char const *argv[]) { int n, k, temp; char str[2]; //freopen("in.c", "r", stdin); while(~scanf("%d%d", &n, &k)) { while(!q.empty()) q.pop(); for(int i = 0;i < n;i ++) { scanf("%s", str); if(str[0] == 'I') { scanf("%d", &temp); q.push(temp); if(q.size() > k) q.pop(); } else printf("%d\n", q.top()); } } return 0; }