word = map(str,raw_input().strip().split()) n = len(word) first_Q ='' first_q ='' for i in range(0,n): if word[i][0] == 'Q' or word[i][0] == 'q': print word[i]