# data[].attributes.body
N, M = map(int, input().split())

card_num = list(map(int, input().split()))

result = 0

for i in range(N):

for j in range(i + 1, N):

for z in range(j + 1, N):

card_combi_sum = card_num[i] + card_num[j] + card_num[z]

if card_combi_sum <= M:

result = max(result, card_combi_sum)

print(result)

# data[].attributes.headline
# exercise 37: A Trio Who Gave up Math in the Mock Test

# data[].attributes.subject
# exercise 37: A Trio Who Gave up Math in the Mock Test

# data[].attributes.attachment_link.readable_text
def find_min_larvae(n, record):
    periods = []
    start_idx = None
    
    for i, char in enumerate(record):
        if char == '#':
            if start_idx is not None:
                periods.append(i - start_idx)
            start_idx = i
    
    if len(periods) == 0:
        return 1
    
    period = min(periods)
    min_larvae = (n + 37) // period
    return min_larvae

n = int(input())
record = input()

result = find_min_larvae(n, record)
print(result)

# data[].attributes.body
list=[13,2,8,22,3,1,18,15,12,5,10,19,6,16,7,20]

input_=int(input())

for i in range(len(list)):

if(input_==list[i]):

print(i)

# data[].attributes.body
n=int(input())

arr=[13,2,8,22,3,1,18,15,12,5,10,19,6,16,7,20]

result=0

for i in arr:

if i==n:

result=arr.index(n)

break

else:

result=-1

print(result)

# data[].attributes.body
def binarySearch(listData, value):

low = 0

high = len(listData) - 1

count = 0

while (low <= high):

mid = (low + high) / 2

if (listData[mid] == value):

return mid

elif (listData[mid] < value):

low = mid + 1

else:

high = mid - 1

return count

# data[].attributes.body
n = int(input())

nums = [13, 2, 8, 22, 3, 1, 18, 15, 12, 5, 10, 19, 6, 16, 7, 20]

result = -1

for i in range(len(nums)):

if n == nums[i]:

result = i

break

print(result)

# data[].attributes.body
a = int(input())

list = [13,2,8,22,3,1,18,15,12,5,10,19,6,16,7,20]

try:

result = list.index(a)

except ValueError:

result = -1

break

print(result)

# data[].attributes.body
n = int(input().strip())

list_sample = list(map(int, input().strip().split()))

m = int(input().strip())

user = map(int, input().strip().split())

for _ in range(m):

for i in user:

if i in list_sample:

print(1)

else:

print(0)

# data[].attributes.body
a=int(input())

b=list(map(int,input().split()))

c=int(input())

d=list(map(int,input().split()))

for i in d:

if i in b:

print(1)

else:

print(0)

# data[].attributes.attachment_link.readable_text
# exam 3: ramen formula

N = int(input())
gi_list = list(input())

shot_point = ''.join(gi_list).count('.')
shot_shap = ''.join(gi_list).count('#')

if shot_point == shot_shap:
    print(N//10)
else:
    print(1)

# data[].attributes.body
n = int(input().strip())
list_sample = list(map(int, input().strip().split()))
m = int(input().strip())
user = map(int, input().strip().split())

for _ in range(m):
    for i in user:
        if i in list_sample:
            print(1)
        else:
            print(0)

# data[].attributes.body
def blackjack(N, M, cards):

max_sum = 0

for i in range(N - 2):

for j in range(i + 1, N - 1):

for k in range(j + 1, N):

current_sum = cards[i] + cards[j] + cards[k]

if current_sum <= M and current_sum > max_sum:

max_sum = current_sum

return max_sum

# 입력 받기

N, M = map(int, input().split())

cards = list(map(int, input().split()))

# 결과 출력

result = blackjack(N, M, cards)

print(result)

# data[].attributes.attachment_link.readable_text
N = int(input())

M = []

for i in range(N):
    M.append(int(input()))

for i in range(len(M)):
    for j in range(len(M)):
        if M[i] < M[j]:
            M[i], M[j] = M[j], M[i]

for n in M:
    print(n)

# data[].attributes.body
# exercise 39: Existence of Integer in Array

n = int(input()) # 정수 개수 N

# N개의 정수 집합(A[1],...,A[N])

nums_a = list(map(int, input().split()))

m = int(input()) # 찾고자 하는 정수 X의 개수

# 찾고자 하는 정수 X 집합

nums_x = list(map(int, input().split()))

"""

이진 탐색으로 구현하기

1. nums_a를 오름차순 정렬

2. 이진 탐색 수행

"""

nums_a.sort() # 오름차순 정렬

for i in range(m): # 정수 X 탐색

low = 0

high = n-1

isExist = False

while low <= high:

mid = int((low + high) / 2)

if nums_x[i] == nums_a[mid]:

isExist = True

print(1)

break

elif nums_x[i] > nums_a[mid]:

low = mid + 1

else:

high = mid - 1

if not isExist:

print(0)

# data[].attributes.body
n = int(input())

nums = [13, 2, 8, 22, 3, 1, 18, 15, 12, 5, 10, 19, 6, 16, 7, 20]

result = -1

for i in range(len(nums)):

if n == nums[i]:

result = i

break

print(result)

# data[].attributes.body
a=int(input())

b=[13,2,8,22,3,1,18,15,12,5,10,19,6,16,7,20]

c=-1

for i in b:

c+=1

if i == a:

print(c)

break

else:

print(-1)

break

# data[].attributes.body
list_sample = [13, 2, 8, 22, 3, 1, 18, 15, 12, 5, 10, 19, 6, 16, 7, 20]

idx = -1

user = int(input().strip())

for i in range(len(list_sample)):

if user == list_sample[i]:

idx = i

break

print(idx)

# data[].attributes.body
n=int(input())
a=[13,2,8,22,3,1,18,15,12,5,10,19,6,16,7,20]
result=-1
for i in range(len(a)):
    if n==a[i]:
        result=i
        break
print(result)