//This is written in C programming language (not C++)!

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_CARDS_COUNT 2000
#define MAX_INPUT_SYMBOLS 12000
//MAX_INPUT_SYMBOLS = 6 * MAX_CARDS_COUNT
//6 times because max card number is 20000, which is 5 digit long
//and there is a one space after each number

void main()
{
    int s, n, i, k, sum = 0, ans = 0, cards[MAX_CARDS_COUNT];
    scanf("%d %d", &s, &n);
    getchar();
    char text[MAX_INPUT_SYMBOLS];
    for (i = 0; i < n; i++)
    {
        cards[i] = 0;
    }
    fgets(text, MAX_INPUT_SYMBOLS, stdin);
    for (i = 0, k = 0; k < n && text[i] != '\n' && text[i] != '\0'; i++)
    {
        if(text[i] >= '0' && text[i] <= '9')
        {
            text[i] -= '0';
            cards[k] *= 10;
            cards[k] += text[i];
        }
        else if(text[i] == ' ')
        {
            k++;
        }
    }
}