from sys import stdin

readline = stdin.readline





import heapq



def main():

    heap = []

    while True:

        line = readline()

        if line[2] == 't':

            print((heapq.heappop(heap)[1]))

        elif line[2] == 's':

            n = int(line.split()[1])

            heapq.heappush(heap, (-n, n))

        else:

            break



main()
from sys import stdin

from heapq import heappop, heappush

readline = stdin.readline





heap = []

while True:

    line = readline()

    if line[1] == 'x':print((-heappop(heap)))

    elif line[0] == 'i':heappush(heap, -int(line.split()[1]))

    else:break
from sys import stdin

readline = stdin.readline
import heapq


def main():
    heap = []
    while True:
        line = readline()
        if line[2] == "t":
            print((heapq.heappop(heap)[1]))
        elif line[2] == "s":
            n = int(line.split()[1])
            heapq.heappush(heap, (-n, n))
        else:
            break


main()

from sys import stdin
from heapq import heappop, heappush

readline = stdin.readline
heap = []
while True:
    line = readline()
    if line[1] == "x":
        print((-heappop(heap)))
    elif line[0] == "i":
        heappush(heap, -int(line.split()[1]))
    else:
        break

+from heapq import heappop, heappush -import heapq - - -def main(): -    heap = [] -    while True: -        line = readline() -        if line[2] == "t": -            print((heapq.heappop(heap)[1])) -        elif line[2] == "s": -            n = int(line.split()[1]) -            heapq.heappush(heap, (-n, n)) -        else: -            break - - -main() +heap = [] +while True: +    line = readline() +    if line[1] == "x": +        print((-heappop(heap))) +    elif line[0] == "i": +        heappush(heap, -int(line.split()[1])) +    else: +        break