INFTY = (1<<30)
$h = 0
$a = []

def maxHeapify(i)
	l = 2 * i
	r = 2 * i + 1
	
	if l <= $h && $a[l] > $a[i]
		largest = l
	else
		largest = i
	end
	largest = r if r <= $h && $a[r] > $a[largest]

	if largest != i
		$a[i], $a[largest] = $a[largest], $a[i]
		maxHeapify(largest)
	end
end

def extract()
	return -INFTY if $h < 1
	maxv = $a[1]
	$a[1] = $a[$h]
	$h -= 1
	maxHeapify(1)
	return maxv
end

def increaseKey(i, key)
	return if key < $a[i]
	$a[i] = key
	while i > 1 && $a[i / 2] < $a[i]
		$a[i], $a[i / 2] = $a[i / 2], $a[i]
		i = i / 2
	end
end

def insert(key)
	$h += 1
	$a[$h] = -INFTY
	increaseKey($h, key)
end

loop do
	line = gets.split
	break if line[0] == "end"
	if line[0] == "insert"
		insert(line[1].to_i)
	else
		puts extract()
	end
end