#!/usr/bin/env python

# -*- coding: utf-8 -*-



while True:

    N,K = list(map(int,input().split()))

    A = sorted([int(eval(input())) for i in range(0,K)])



    if (N,K) == (0,0):

        break



    if A[0] == 0:

        flag = True

        A = A[1:]

        K -= 1

    else:

        flag = False



    ans = 0

    count = 0

    diff_list = []

    s = 0

    for i in range(1,K):

        if A[i] - A[i-1] == 2:

            diff_list.append(A[i-1] - A[s])

            s = i

            count = 0

        elif A[i] - A[i-1] > 2:

            diff_list.append(A[i-1] - A[s])

            diff_list.append(0)

            s = i

            count = 0

        else:

            count += 1

            ans = max(ans,count)

    else:

        diff_list.append(A[i] - A[s])



    if flag is True:

        ans = 0

        for i in range(1,len(diff_list)):

            ans = max(ans,diff_list[i] + diff_list[i-1] + 2)



    print((ans + 1))
#!/usr/bin/env python

# -*- coding: utf-8 -*-



while True:

    N,K = list(map(int,input().split()))

    A = sorted([int(input()) for i in range(0,K)])



    if (N,K) == (0,0):

        break



    if A[0] == 0:

        flag = True

        A = A[1:]

        K -= 1

    else:

        flag = False



    ans = 0

    count = 0

    diff_list = []

    s = 0

    for i in range(1,K):

        if A[i] - A[i-1] == 2:

            diff_list.append(A[i-1] - A[s])

            s = i

            count = 0

        elif A[i] - A[i-1] > 2:

            diff_list.append(A[i-1] - A[s])

            diff_list.append(0)

            s = i

            count = 0

        else:

            count += 1

            ans = max(ans,count)

    else:

        diff_list.append(A[i] - A[s])



    if flag is True:

        ans = 0

        for i in range(1,len(diff_list)):

            ans = max(ans,diff_list[i] + diff_list[i-1] + 2)



    print((ans + 1))
#!/usr/bin/env python
# -*- coding: utf-8 -*-
while True:
    N, K = list(map(int, input().split()))
    A = sorted([int(eval(input())) for i in range(0, K)])
    if (N, K) == (0, 0):
        break
    if A[0] == 0:
        flag = True
        A = A[1:]
        K -= 1
    else:
        flag = False
    ans = 0
    count = 0
    diff_list = []
    s = 0
    for i in range(1, K):
        if A[i] - A[i - 1] == 2:
            diff_list.append(A[i - 1] - A[s])
            s = i
            count = 0
        elif A[i] - A[i - 1] > 2:
            diff_list.append(A[i - 1] - A[s])
            diff_list.append(0)
            s = i
            count = 0
        else:
            count += 1
            ans = max(ans, count)
    else:
        diff_list.append(A[i] - A[s])
    if flag is True:
        ans = 0
        for i in range(1, len(diff_list)):
            ans = max(ans, diff_list[i] + diff_list[i - 1] + 2)
    print((ans + 1))

#!/usr/bin/env python
# -*- coding: utf-8 -*-
while True:
    N, K = list(map(int, input().split()))
    A = sorted([int(input()) for i in range(0, K)])
    if (N, K) == (0, 0):
        break
    if A[0] == 0:
        flag = True
        A = A[1:]
        K -= 1
    else:
        flag = False
    ans = 0
    count = 0
    diff_list = []
    s = 0
    for i in range(1, K):
        if A[i] - A[i - 1] == 2:
            diff_list.append(A[i - 1] - A[s])
            s = i
            count = 0
        elif A[i] - A[i - 1] > 2:
            diff_list.append(A[i - 1] - A[s])
            diff_list.append(0)
            s = i
            count = 0
        else:
            count += 1
            ans = max(ans, count)
    else:
        diff_list.append(A[i] - A[s])
    if flag is True:
        ans = 0
        for i in range(1, len(diff_list)):
            ans = max(ans, diff_list[i] + diff_list[i - 1] + 2)
    print((ans + 1))

-    A = sorted([int(eval(input())) for i in range(0, K)]) +    A = sorted([int(input()) for i in range(0, K)])