#!python3 # get number of people and number of messages people, messages = map(int, input().split()) # messages = int(input()) # count of total/global unread messages total_unread = 0 # dictionary, key is person (1-n), value is index of last message they read/sent last_read = {} # read in and process messages for message_number in range(1, messages+1): sender = int(input()) # read sender # what was the last message this sender read/sent? if sender in last_read: sender_last_read = last_read[sender] else: sender_last_read = 0 # this new message gets sent to all other people # sender reads it, so add people-1 to total unread count total_unread += people-1 # in sending this message, the sender has read any # previously unread messages in their queue # so subtract these now-read messages from unread total total_unread -= (message_number - sender_last_read - 1) # update last read for this sender last_read[sender] = message_number # print total unread count after this message is sent print(total_unread)