#! python

import os
import sys

def basename(s, postfix):
	x = os.path.basename(s)
	if postfix and x.endswith(postfix):
		return x[:-len(postfix)]
	return x


def main(infd, outfd, postfix):
	for line in infd:
		outfd.writelines([basename(line.strip(), postfix), '\n'])


if __name__ == '__main__':
	if len(sys.argv) > 1:
		postfix = sys.argv[1]
	else:
		postfix = ''
	main(sys.stdin, sys.stdout, postfix)
