#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include <list>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

/* template end */

using ll = long long;
using P=std::pair<long long,long long>;

class Fibonacci_Heap{
  private:

  struct Node{
    long long val;
    std::size_t deg;
    bool mark;
    Node *par,*ch;
    Node *left,*right;
    Node(long long val_=0):val(val_),deg(0),mark(false),par(nullptr),ch(nullptr),left(this),right(this){}
    ~Node(){
      par=nullptr;
      if(ch){delete ch;ch=nullptr;}
      if(left)left->right=nullptr;
      if(right)delete right;
      right=nullptr;
      left=nullptr;
    }
    //thisの子にvを追加する vはparを持たないことが保障される
    Node *insert_ch(Node *v){
      deg++;
      if(!ch){
        ch=v;
        v->par=this;
        return v;
      }
      Node *tmp=ch->right;
      ch->right=v;v->left=ch;
      tmp->left=v;v->right=tmp;
      v->par=this;
      return this;
    }
    //thisの子であるvをcutする thisの子にvが含まれていることが保障される
    Node *cut_ch(Node *v){
      deg--;
      v->par=nullptr;
      if(deg==0){
        ch=nullptr;
        return v;
      }
      Node *l=v->left,*r=v->right;
      l->right=r;r->left=l;
      ch=r;
      v->left=v;v->right=v;
      return this;
    }
  };

  Node *min_ptr;
  std::size_t n;

  public:

  Fibonacci_Heap():min_ptr(nullptr),n(0){}
  Fibonacci_Heap(const Fibonacci_Heap&)=delete;
  Fibonacci_Heap& operator=(const Fibonacci_Heap&)=delete;
  ~Fibonacci_Heap(){
    if(min_ptr)delete min_ptr;
    min_ptr=nullptr;
  }

  bool empty(){return !min_ptr;}
  std::size_t size(){return n;}

  
  long long top(){assert(min_ptr);return min_ptr->val;}

  Node *insert(long long val){
    n++;
    Node *tmp=new Node(val);
    if(!min_ptr){
      min_ptr=tmp;
      return tmp;
    }
    Node *right=min_ptr->right;
    min_ptr->right=tmp;tmp->left=min_ptr;
    right->left=tmp;tmp->right=right;
    if(min_ptr->val>val)min_ptr=tmp;
    return tmp;
  }

  void pop(){
    assert(min_ptr);
    if(n==1){
      delete min_ptr;
      min_ptr=nullptr;
      n--;
      return;
    }

    if(min_ptr->ch){
      Node *tmp=min_ptr->ch;
      tmp->par=nullptr;tmp->mark=false;
      while(tmp->right!=min_ptr->ch){
        tmp=tmp->right;
        tmp->par=nullptr;tmp->mark=false;
      }
      Node *l=min_ptr->ch,*r=min_ptr->ch->left;
      min_ptr->ch=nullptr;
      Node *root_r=min_ptr->right;
      min_ptr->right=l;l->left=min_ptr;
      root_r->left=r;r->right=root_r;
    }

    Node *l=min_ptr->left,*r=min_ptr->right;
    l->right=r;min_ptr->left=nullptr;
    r->left=l;min_ptr->right=nullptr;
    delete min_ptr;//min_ptrの解放
    n--;

    //木のマージ
    std::size_t cnt=0;
    {
      std::size_t temp=n+1;
      while(temp>0){
        cnt++;
        temp>>=1;
      }
    }

    std::vector<Node *> deg_list(2*cnt+1,nullptr);
    Node *now=r->right;
    r->right=r;r->left=r;
    deg_list[r->deg]=r;
    while(now!=r){
      Node *temp=now;
      now=now->right;
      temp->left=temp;temp->right=temp;
      while(deg_list[temp->deg]){
        std::size_t deg=temp->deg;
        if(deg_list[deg]->val < temp->val){
          deg_list[deg]->insert_ch(temp);
          temp=deg_list[deg];
        }else{
          temp->insert_ch(deg_list[deg]);
        }
        deg_list[deg]=nullptr;
      }
      deg_list[temp->deg]=temp;
    }

    Node *banpei=new Node();
    Node *temp=banpei;
    for(auto&& e:deg_list){
      if(e){
        temp->right=e;
        e->left=temp;
        temp=e;
      }
    }
    temp->right=banpei->right;
    banpei->right->left=temp;
    banpei->right=banpei;
    delete banpei;banpei=nullptr;

    min_ptr=temp;
    now=temp->right;
    while(now!=temp){
      if(now->val < min_ptr->val)min_ptr=now;
      now=now->right;
    }

  }

};

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  std::priority_queue<ll> que;

  std::string s;
  while(std::cin>>s){
    if(s=="end")break;
    if(s=="insert"){
      ll n;
      std::cin>>n;
      que.push(n);
    }else{
      std::cout<<que.top()<<"\n";
      que.pop();
    }
  }

  return 0;
}


Measured memory_bytes: 11232