def ss(st):
    flag = True

    if len(st) % 2 != 0:
        flag = False
    else:
        n = len(st) // 2
        for i in range(n):
            if st[i] != st[i+n]:
                flag = False
                break
    return flag

S = input()
for i in range(len(S)-1, 0, -1):
    temp = S[0:i]
    if ss(temp):
        print(len(temp))
        break


a=input()
num=len(a)

num=num-2

for i in range(num,0,-1):
    a=a[:i]
    nums=int(i/2)
    s=a[:nums]
    if str(s)*2==str(a):
        print(len(a))
        break


#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import division, print_function
import sys

def main():
    s = sys.stdin.readline().strip()
    while True:
        s = s[:-2]
        i = len(s) // 2
        a = s[:i]
        b = s[i:]
        if a == b:
            print(len(s))
            return

if __name__ == '__main__':
    main()


def main():
    S = input().strip()
    for i in range(2, len(S), 2):
        part = S[:-i]
        p = len(part) // 2
        if part[:p] == part[p:]:
            print(p * 2)
            break

if __name__ == '__main__':
    main()


S = input()
while True:
    S = S[:-1]
    if len(S)%2==0:
        if S[0:int(len(S)/2)] == S[int((len(S)/2)):]:
            print(len(S))
            break


# -*- coding:utf-8 -*-
s = input()[:-1]

while True:
    l = len(s)
    if s[:l//2] == s[l//2:]:
        break
    s = s[:-1]

print(len(s))


# coding: utf-8

def is_even(s):
    return s[:int(len(s)/2)] == s[int(len(s)/2):]

ss = input()
diff = 2
while True:
    if is_even(ss[:len(ss) - diff]):
        break
    else:
        diff += 2

print(len(ss) - diff)


S = input()
T = list(S)
flag = 0

while flag == 0:
	del T[len(T)-1]
	del T[len(T)-1]
	if T[0:len(T)//2] == T[len(T)//2:len(T)]:
		flag = 1
		print(len(T))


# coding: utf-8
def get_ln_inputs():
    return input().split()

def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))

def is_ev_st(s):
    l = len(s)
    if l % 2 == 1:
        return False
    l2 = int(l / 2)
    return s[:l2] == s[l2:]

def main():
    S = get_ln_inputs()[0][:-1]
    while not is_ev_st(S):
        S = S[:-1]
    print(len(S))

main()


def isEvenstring(s):
	l = len(s)
	center = int(l/2)
	if l%2 == 0:
		return s[:center]==s[center:]

	else:
		return False

if __name__ == '__main__':
	string = input()
	l = len(string)
	for i in range(1, l):
		if isEvenstring(string[:-i]):
			print (l - i)
			break


s = input()
n = len(s)
def iseven(str, n):
    for i in range(0, n//2):
        if str[i] != str[i+n//2]:
            return False
    else:
        return True

for i in range(2, n, 2):
    if iseven(s, n-i):
        print(n-i)
        break


def check_gu(s):
    n = len(s)
    if n%2!=0:
        return False
    return s[:n//2] == s[n//2:]

if __name__ == '__main__':
    s=input()

    for i in range(1,len(s)):
        ss = s[:len(s)-i]
        if(check_gu(ss)):
            print(len(ss))
            break


s = raw_input()
i = len(s) - 2
while(len(s)):
    if i % 2 == 0 and s[0:i/2] == s[i/2:i]:
        print i
        break
    i-=1


import sys

S = input()
n = len(S) // 2

for i in range(1, n):
    if S[0:n - i] == S[n - i: 2 * n - 2 * i]:
        print((n - i) * 2)
        sys.exit()


s = raw_input()

def is_rep(s0):
    l = len(s0)/2
    s1 = s0[:l]
    s2 = s0[l:]
    return s1 == s2

l = len(s)
while True:
    l -= 2
    if is_rep(s[:l]):
        break
print l


S = raw_input()
n = len(S)

ans = 0
for k in range((n+1)/2):
    if S[:k] == S[k:2*k]:
        ans = k * 2
print ans


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

s = raw_input()
flg = 1
slen = len(s)
while(flg):
    s = s[:slen-2]
    slen = len(s)
    m = slen/2
    if(s[:m]==s[m:]):
        print(2*m)
        flg = 0


s=raw_input()
for j in range(len(s)-1,-1,-1):
    p=s[:j]
    if len(p)%2==0:
        s1=p[:len(p)/2]
        s2=p[len(p)/2:]
        if s1==s2:
            print j
            exit()


S = input()
S = S[:int(len(S)-1)]
while True:

	if S[:int(len(S)/2)] == S[int(len(S)/2):]:
		print(int(len(S)))
		break
	else:
		S = S[:int(len(S)-1)]


import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    s = S()
    e = set()
    r = len(s)
    for i in range(r-2,-1,-2):
        if s[:i//2] == s[i//2:i]:
            return i
    return -1

print(main())


s = input()
rm=0
for i in range(len(s)):
    if len(s)%2 !=0:
        s = s[:-1]
        rm += 1
        continue
    if s[0:len(s)//2] == s[len(s)//2:len(s)] and rm > 0:
        break
    else:
        s = s[:-1]
        rm += 1
print(len(s))


def main():
    S = input()

    s = S
    while True:
        s = s[:-2]
        l = len(s) // 2
        if s[:l] == s[l:]:
            ans = len(s)
            break

    print(ans)

main()


string = input()

if len(string)%2==0 :
    string = string[:-2]
else :
    string = string[:-3]
length = len(string)

while length>0 :
    if string[:length//2]==string[length//2:] :
        print(length)
        break
    length -= 2
    string = string[:-2]


S=str(input())
s=len(S)
for i in range(1,s):
  if (s-i)%2==0 and S[0:int((s-i)/2)]==S[int((s-i)/2):s-i]:
    print(int((s-i)))
    break


s = input()

if len(s) % 2 != 0:
    s = s[:len(s)-1]
else:
    s = s[:len(s)-2]

for i in range(len(s)//2):
    if s[:len(s)//2-i] == s[len(s)//2-i:len(s)-2*i]:
        print(len(s)-2*i)
        exit()


s = input()
for i in range(1, len(s)):
    if((len(s)-i) % 2 == 0):
        ans = len(s) - i
        if(s[0:ans//2] == s[ans//2:ans]):
            print(ans)
            break


S = input()
S = S[:-1]
while True:
	if len(S) % 2 == 0:
		halflen = int(len(S) / 2)
		if S[:halflen] == S[halflen:]:
			print(len(S))
			break
	S = S[:-1]


S=input()
s=S[0:-1]

i=0
L=[]

for i in range(len(s)):

    if s[0:i]==s[i:(2*i)]:
        L.append(2*i)

print(max(L))


char = input()
char = char[0:-1]
while(1):
    if char[:(len(char)//2)] == char[len(char)//2:]:
        break
    else :
        char = char[0:-1]
print(len(char))


s = input()

while True:
    s = s[:-2]
    n = len(s)
    w1 = s[:int(n / 2)]
    w2 = s[int(n / 2):]
    if w1 == w2:
        print(n)
        break


moji = input()
def isEvenStr(moji):
	length = len(moji)
	if length % 2 == 1:
		return None
	else:
		firsthalf = moji[0:int(length/2)]
		latterhalf = moji[int(length/2):int(length)]
		return firsthalf == latterhalf

for i in range(len(moji)-1,0,-1):
	trimmed = moji[0:i]
	isEven = isEvenStr(trimmed)
	if isEven:
		print(i)
		break


S = input()

for i in range(1, len(S)):
    if len(S[:-i]) % 2 == 1:
        continue
    if S[:int(len(S[:-i])/2)] == S[int(len(S[:-i])/2):-i]:
        ans = len(S[:int(len(S[:-i]))])
        break
print(ans)


s = raw_input()
for i in range(len(s)-2, 0, -2):
    t = s[0:i/2]
    u = s[i/2:i]
    if t == u:
        print i
        break


if(__name__ =="__main__"):
    S = input()
    for i in range(1,len(S)):
        tmp = S[:-i]
        tmplen = len(tmp)
        #print(tmplen)
        if(tmplen % 2 == 0):
            #print(tmp[:int(tmplen/2)])
            if(tmp[:int(tmplen/2)] == tmp[int(tmplen/2):]):
                print(tmplen)
                break


S = input()

ans = len(S) - 2
while ans:
    if S[0:(ans // 2)] == S[(ans // 2):ans]:
        break

    ans -= 2

print(ans)


S = input()

if len(S) % 2 == 1:
    S = S[:-1]

flag = 0
while flag == 0:
    S = S[:-2]
    ans = int(len(S) / 2)
    same_char = 0
    i = 0
    while i < ans:
        if S[i] == S[ans + i]:
            same_char += 1
        else:
            break
        i += 1
    if ans == same_char:
        flag = 1

print(len(S))


S = input()
for i in range(len(S)-1, 0, -1):
    str = S[0:i]
    if str[0:int(len(str)/2)] == str[int(len(str)/2):]:
        print(len(str))
        break


S = raw_input()

S=S[:-2]
mid=len(S)/2
Sf=S[:mid]
Sl=S[mid:]

while Sf!=Sl:
  S=S[:-2]
  mid=len(S)/2
  Sf=S[:mid]
  Sl=S[mid:]

print(len(S))


# -*- coding:utf-8 -*-
s = input()
sub = 0
for tmp in reversed(range(1,len(s)-2,2)):
    factor = s[0:tmp+1]
    sub += 2
    if factor[0:int(len(factor)/2)] == factor[int(len(factor)/2):len(factor)]:
        break
    else:
        pass
print(len(s)-sub)


def check(s):
    if len(s)%2 !=0:
        return False
    i=int(len(s)/2)
    s1=s[:i]
    s2=s[i:]
    return s1==s2

s = input()
while True:
    s = s[:len(s)-1]
    if check(s):
        print(len(s))
        break


S = raw_input()
flag = 0
S = S[:-1]
while(len(S) > 0):
  if len(S) % 2 == 1:
     S = S[:-1]
  else:
     a = S[:len(S)/2]
     b = S[len(S)/2:]
     if a == b:
        ans = S
        break
     S = S[:-1]
print len(S)


S = str(input())
S = S[:-1]

hantei = False
while hantei == False:
    if len(S) % 2 == 1:
        S = S[:-1]
    else:
        half = int(len(S)/2)
        last = int(len(S))
        if S[0:half] == S[half:last]:
            print(last)
            hantei = True
        else:
            S = S[0:-1]


def check(s):
    l = len(s)
    return True if s[:l / 2] == s[l / 2:] else False

S = raw_input()[:-1]
if len(S) % 2 != 0:
    S = S[:-1]
L = len(S)
for i in range(L):
    if check(S):
        break
    else:
        S = S[:-2]

print len(S)


a = input().strip()
for i in range((len(a))//2-1,0,-1):
   if a[:i] == a[i:2*i]:
      print(2 * i)
      break


# -*- coding: utf-8 -*-
def check_word(word):
    return word[:int(len(word)/2)] == word[int(len(word)/2):len(word)]

a = input()
count = 0
for i in range(1, len(a)):
    b = a[:-i]
    if check_word(b):
        count = len(b)
        break
print(count)


#s = list(input())
s = input()
n = len(s)
count = 1   #消した数

if n % 2 == 1 - count:
    count += 1

while s[0 : int((n-count)/2)] != s[int((n-count)/2) : n-count]:
    count += 2

print(n-count)


from collections import deque
def main():
    s=deque(input())
    for i in range(0,len(s)):
        s.pop()
        if len(s)%2==1:
            continue
        else:
            if "".join(s)[0:len(s)//2]=="".join(s)[len(s)//2:len(s)]:
                print(len(s))
                break;
if __name__=='__main__':
    main()


def f(x):
    return len(x) % 2 == 0 and x[:len(x)//2] == x[len(x)//2:]

x=input()[:-1]
while not f(x):
    x=x[:-1]

print(len(x))


S = input()
l = len(S)

for i in range(1, l//2):
  if S[:l//2-i] == S[l//2-i:l-2*i]:
    print(l-2*i)
    break


#! /usr/bin/env python3

s = input()[::-1]
s = s[1:]
s = s[len(s) % 2:]
for i in range(0, len(s), 2):
    t = s[:len(s) // 2]
    if s == t * 2:
        print(len(s))
        break
    s = s[2:]


S=str(input())
s=len(S)
for i in range(1,s):
 if (s-i)%2==0 and S[0:int((s-i)/2)]==S[int((s-i)/2):s-i]:
  print (int(s-i))
  break


#ss
s = input()
if ( len(s)%2 ==1 ):
    s = s[:-1]
else:
    s = s[:-2]

while 1:
    l = int(len(s)/2)
    if (s[:l]==s[l:] ):
        print(l*2)
        break
    else:
        s = s[:-2]
    if ( len(s)==0 ):
        break


s=input()
while True:
    s=s[:-1]
    l=len(s)
    if(l%2==1):
        continue
    else:
        if(s[:int(l/2)]==s[int(l/2):]):
            print(l)
            break


def main():
    msg = input()
    msg = msg[:-1]
    if len(msg) % 2 != 0:
        msg = msg[:-1]
    while len(msg) >= 2:
        before = msg[:int(len(msg) / 2)]
        after = msg[int(len(msg) / 2):]
        if before == after:
            print(len(msg))
            break
        msg = msg[:-2]

if __name__ == '__main__':
    main()


str=input()
k=len(str)
str=str[0:k-2]
while True:
    n=int(len(str)/2)
    a=str[:n]
    b=str[n:]
    if a==b:
        print(len(a)*2)
        break
    k=len(str)
    str=str[0:k-2]


s=input()
for i in range(len(s)):
	if s[0:i//2]==s[i//2:i]:
		ans=i
print(ans)


letters = input()
while True:
    not_equal = 0
    length = len(letters)
    letters = letters[:length-1]
    if len(letters) % 2 != 0:
        continue

    if int(len(letters)) % 2 == 0:
        half = int(len(letters)/2 -1)
    else:
        half = int((len(letters)-1)/2)
    i = 0
    while i <= half:
        if letters[i] != letters[i + half + 1]:
            not_equal = 1
            break
        i += 1

    if not_equal == 0:
        print(len(letters))
        break


import sys
def judge(s):
    if len(s)%2 == 1:
        return False
    half = len(s)//2
    for i in range(half):
        if s[i] != s[i+half]:
            return False
    return True

S = input()
for i in range(1,len(S)):
    if judge(S[:-i]):
        print(len(S[:-i]))
        sys.exit()
print(0)


# coding: utf-8

import numpy as np

if __name__=="__main__":
    s = input().replace("\n", "")
    n = len(s)
    ss = ""
    if n%2 == 1:
        s = s[0:n-1]
        n = len(s)
    elif n%2 == 0:
        s = s[0:n-2]
        n = len(s)

    for i in list(range(0,n,2)):
        ss = s[0:n-i]
        m = len(ss)
        if ss[0:int(m/2)] == ss[int(m/2):m]:
            print(len(ss))
            break


def even(s):
    if len(s) % 2 != 0: return False
    a = s[:len(s)//2]
    return 2*a == s

s = list(input())
s.pop()
while not even(s): s.pop()
print(len(s))


import sys
S = list(input())

ans = len(S)
if len(S)%2 == 1 :
    S = S[0:-1]
    ans -= 1
    if S[0:ans//2] == S[ans//2:] :
        print(ans)
        sys.exit()

while len(S) > 0 :
    S = S[0:-2]
    ans -= 2
    if S[0:ans//2] == S[ans//2:] :
        print(ans)
        sys.exit()
else :
    print(ans)


S = list(input())[:-1]

while True:
  S.pop()

  if len(S) % 2 != 0:
    continue

  if S[:len(S) // 2] * 2 == S:
    break

print(len(S))


import math

def f():
    a  = input()
    for i in range(1,len(a)):
        l = len(a) - i
        if l%2==1:
            continue
        d = l//2

        if a[:d] == a[d:-i]:
            print(d*2)
            return

f()


s = input()

for i in range(len(s)):
    s = s[:-1]
    if len(s) % 2 == 1:
        continue
    ss = s[len(s)//2:]
    flag = True
    for j in range(len(ss)):
        if ss[j] != s[j]:
            flag = False
            break
    if flag:
        print(len(s))
        break
    s = s[:-1]


# -*- coding: utf-8 -*-
s = input()
N = len(s)

for i in range(1, N):
    if i % 2 == 1:
        continue
    a = s[:((N-i)//2)]
    b = s[((N-i)//2):(N-i)]
    if a == b:
        print(N-i)
        break


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

#-------
# Initialize
S = str(input())[:-1]

#-------
# Define
def check(s):
    if len(s) % 2 == 1:
        return False
    if (s[:int(len(s)/2)] == s[int(len(s)/2):]):
        return True
    else:
        return False

#-------
# Do
while (len(S) > 0):
    if check(S):
        print(len(S))
        break
    else:
        S = S[:-1]

#-------
# Output


def main():
    s = input()

    length = None
    for i in range(1, len(s)-1):
        tmp = s[:len(s)-i]
        if len(tmp)%2 != 0:
            continue
        elif tmp[:len(tmp)//2] == tmp[len(tmp)//2:]:
            length = len(tmp)
            break
    print(length)

if __name__ == "__main__":
    main()


s = raw_input()
p = len(s) - 2
while(p>0):
    if s[0:p/2] == s[p/2:p]:
        break
    p -= 2
print p


S = input()
ret = 0
for i in range(1, len(S) // 2):
    if S[:i] * 2 == S[:i * 2]:
        ret = i * 2
print(ret)


s = input()

def r(s):
    l = len(s)
    if(l%2 == 1):
        return r(s[:-1])
    elif(s[:int(l/2)] == s[int(l/2):]):
        return len(s)
    else:
        return r(s[:-1])
print(r(s[:-1]))


str = input()
while True:
    str = str[:-2]
    n = len(str)
    if str[:int(n/2)] == str[int(n/2):]:
        print(n)
        break


s = input()

s = s[:-1]

if len(s) % 2 != 0:
    s = s[:-1]

while True:
    if s[:len(s) // 2] == s[len(s) // 2:]:
        print(len(s))
        break
    else:
        s = s[:-2]


c=0
i=0
list1=[]
list2=[]

S = input('')
char_list = list(S)
c = len (char_list)
c= c-1
#print(c)

while c>1:
	if c % 2 == 0:
		d=int(c/2)
		#print (d)
		for i in range(d):
			list1.append(char_list[i])
			list2.append(char_list[i+d])
		#print (list1)
		#print(list2)

		if list1 == list2:
			print (len (list1)*2)
			break

		list1=[]
		list2=[]
	c=c-1


s = list(input())
for i in range(int(len(s)/2)-1):
    s = s[:-2]
    sep = int(len(s)/ 2)
    a = s[:sep]
    b = s[sep:]
    if a == b:
        print(int(len(a)*2))
        break


N = input()
for i in range(1,len(N)):
    num = (len(N)-i)//2
    if N[:num] == N[num:len(N)-i]:
        print(len(N[:num])*2)
        break


import sys, math, itertools, collections, heapq
sys.setrecursionlimit(10 ** 7)
pinf = float("inf")
ninf = -float("inf")

slist = list(input())

def f(s):
        l = len(s)
        l2 = l // 2
        if l % 2 != 0:
                return 0
        s1 = s[0:l2]
        s2 = s[l2:]
        if s1 == s2:
                return l
        else:
                return 0

if len(slist) == 2:
        ans = f(slist)
        if ans != 0:
                print(1)
else:
        while len(slist) >= 3:
                slist.pop()
                slist.pop()
                ans = f(slist)
                if ans != 0:
                        print(ans)
                        break


data=list(map(str,input()))
del data[-1]
while len(data):
    m = len(data)//2
    if data[:m]==data[m:]:
        print(len(data))
        break
    del data[-1]
else:
    print(0)


s = input()
for i in range(len(s)):
    s = s[:-1]
    h = int(len(s)/2)
    if len(s) % 2 == 0:
        if s[:h] == s[h:]:
            print(len(s))
            break


s=list(raw_input())
while len(s) > 1:
    s.pop()
    left="".join(s[:len(s)/2])
    right="".join(s[len(s)/2:])
    if left == right:
        print len(left+right)
        exit()
print 0


doc = input()
for i in range(1,len(doc)):
    tmp_doc = doc[:-i]
    length = len(tmp_doc)
    if length%2==0 and tmp_doc[:length//2] == tmp_doc[length//2:]:
        print(length)
        break


s = input()

while True:
    s = s[:-1]
    L = len(s)
    if L%2 != 0:
        continue

    ok = True
    for i in range(L//2):
        if s[i] != s[L//2+i]:
            ok = False
    if ok:
        break

print(len(s))


s = input()
s = s[:len(s) - 1]
if len(s) % 2 != 0:
	s = s[:len(s) - 1]

while True:
	mid = int(len(s) / 2)
	if s[:mid] == s[mid:]:
		print(len(s))
		break
	else:
		s = s[:len(s) - 1]


s = input()[:-2]
half = len(s)//2

for i in range(half):
    t_h = len(s)//2
    if s[:t_h] == s[t_h:]:
        print(len(s))
        break
    else:
        s = s[:-2]


s = input()

length = len(s) - 2

def guumoji(s):
    length = len(s)

    if s[:length//2] == s[length//2:]:
        return True

    return False

while length > 0:
    if guumoji(s[:length]):
        break

    length -= 2

print(length)


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

S = raw_input()

for i in range(len(S)-2,0,-2):
    if S[0:i/2] == S[i/2:i]:
        print i
        exit()


#Python
import sys

S = raw_input()

if len(S)%2==1:
	S=S[0:len(S)-1]

if S[0:len(S)/2]==S[len(S)/2:]:
	S=S[0:len(S)-2]

#print S
cnt=len(S)
while cnt>1:
	#print "cnt:::"+str(cnt)
	S1=S[0:len(S)/2]
	S2=S[len(S)/2:]
	#print S1
	#print S2
	if S1==S2:
		print len(S)
		sys.exit()

	S=S[0:len(S)-2]
	cnt-=2


def solve(s):
    L = len(s)
    L -= 1
    if L % 2 == 1:
        L -= 1
    while L >= 2:
        if s[:L/2] == s[L/2:L]:
            return L
        L -= 2
    return 0

def main():
    s = raw_input().rstrip()
    print solve(s)

if __name__ == '__main__':
    main()


S=raw_input()

i=2
while(i<=len(S)-2):
    s=S[0:-1*i]
    if s[0:len(s)/2]==s[len(s)/2:]:
        print len(s)
        break
    i+=2

if len(S)==2:
    print 1


def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

s = rls()
if(len(s) % 2 == 1):
    s.remove(s[-1])
else:
    s = s[:-2]
for i in range(len(s) // 2):
    if(s[:len(s)//2] == s[len(s)//2:]):
        print(len(s))
        break
    s = s[:-2]


#!/usr/bin/python

ss = raw_input()

while(True):
  ss = ss[:-1]
  leng = len(ss)
  former = ss[:leng/2]
  later  = ss[leng/2:]

  if former == later:
    leng = len(former) + len(later)
    break

print(leng)


string = list(input())
string.pop()
string.pop()
while "".join(string[:len(string) // 2]) != "".join(string[len(string) // 2:]):
	#print("".join(string[:len(string) // 2]), "".join(string[len(string) // 2:]))
	string.pop()
	string.pop()
# print("".join(string[:len(string) // 2]), "".join(string[len(string) // 2:]))
print(len(string))


s = input()
s_length = len(s)

for i in range(1, s_length):
    if (s_length - i) % 2 != 0:
        continue
    mid = (s_length - i) // 2
    if s[:mid] == s[mid:s_length-i]:
        print(s_length - i)
        break
if s_length == 2:
    print(2)


s = input()
for n in reversed(range(len(s)-1)):
    if s[0:n//2] == s[n//2+1:n]:
        print(n+1)
        break


S = input()
for i in range(len(S) - 1, 0, -1):
    if(S[0:i//2] == S[i//2:i]):
        print(i)
        break


S = input()
L = len(S)
if(L%2!=0):
    L-=1
else:
    L-=2
for i in range(L,0,-2):
    if(S[0:(i//2)]==S[(i//2):i]):
        print(i)
        break
else:
    print("0")


S = input()
while len(S) != 0:
    S = S[:len(S)-1]
    if len(S)%2 != 0:
        continue
    th = len(S)//2
    if S[:th] == S[th:]:
        print(2*len(S[:th]))
        break


S=input()
s=S[0:-1]

for i in range(len(s)-1,-1,-1):
    if s[0:i]==s[i:(2*i)]:
        print(2*i)
        break


#! -*- coding:utf-8 -*-
s = str(input())
s = list(s)
#print(s)
a = 'x'
b = 'x'

for i in range(len(s)):
    s.pop()
    if len(s) % 2 == 0:
        a = s[:len(s)//2]
        b = s[len(s)//2:]
        if a == b:
            print(len(s))
            break


s=input()

n=len(s)

def isok(s):
    n=len(s)
    if n%2==0:
        m=int(n/2)
        if s[0:m]==s[m:n]: return True
    return False

for i in range(n-1,0,-1):
    s=s[0:i]
    if isok(s): print(i) ; break


S = input()
n = len(S)
for i in range(n):
	X = S[0:-2 * (i + 1)]
	x = S[0:int(n / 2) - i - 1]
	if X == x + x:
		count = i + 1
		break

print(n - count * 2)


S = list(input())
n = len(S)

for i in range(n, 0, -1):
    del S[len(S)-1]
    if len(S)%2 == 0:
        str1=""
        str2=""
        for j in range(int(len(S)/2)):
            str1 = str1 + S[j]
        for j in range(int(len(S)/2), len(S)):
            str2 = str2 + S[j]
        if str1 == str2:
            print(len(S))
            break


s = list(str(input()))
s.pop(-1)
if len(s) % 2 != 0:
    s.pop(-1)
while True:
    if s[:len(s)//2] == s[len(s)//2:]:
        print(len(s))
        break
    s.pop(-1)


ss = input()
m = 0
for start in range(len(ss)//2):
    for end in range(start, len(ss) - 1):
        if len(ss[start:end]) > 0:
            if ss[start:end] == ss[end:2*end - start]:
                if (2*end - start) < len(ss):
                    m = max(m, 2*len(ss[start:end]))
print(m)


S=str(input())
L=len(S)
for i in range(1,L//2):
    Strimed=S[:L-2*i]
    Ltrimed=L-2*i
    if Strimed[:Ltrimed//2]==Strimed[Ltrimed//2:]:
        print(Ltrimed)
        exit()


S = raw_input()

for i in range(len(S) - 1):
    S = S[:-1]
    if len(S) % 2 == 0:
        if S[:len(S)/2] == S[len(S)/2:]:
            break

print(len(S))


st=input()
num=len(st)
for x in range(1,num+1):
    st = list(st)
    del st[-1:]
    st = "".join(st)
    n=len(st)
    if n%2==0:
        p=int(n/2)
        st1=st[:p]
        st2=st[-p:]
        if st1==st2:
            print(len(st))
            break
        else:
            continue
    else:
        continue


#!/usr/bin
# -*- coding="utf-8" -*-

s = input()[:-1]
sn = len(s)

if sn % 2 == 1:
  sn = sn -1
for i in range(sn, 0, -2):
  if s[:i//2] == s[i//2:i]:
    break
print(len(s[:i]))


s = input()
for i in range(len(s)-1, 0, -1):
	if i % 2 != 0:
		continue
	_i = int(i/2)
	_s1 = s[:_i]
	_s2 = s[_i:i]
	if _s1 == _s2:
		print(i)
		break


import math
inf=float('inf')
s = input()
s=s[:-1]

if (len(s)%2==1):
    s=s[:-1]

N=len(s)

for i in range(N):
    h=int(len(s)/2)
    if (s[0:h-1]==s[h:-1]):

        print(len(s))
        quit()
    s=s[:-2]

quit()


from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10

def main():
    S = input()
    for i in range(len(S)):
        T = S[:-i - 1]
        if len(T) % 2 == 0 and T[len(T) // 2:] == T[:len(T) // 2]:
            print(len(T))
            break

if __name__ == '__main__':
    main()


# -*- coding: utf-8 -*-
"""
http://abc066.contest.atcoder.jp/tasks/abc066_b

"""
import sys
from sys import stdin
input = stdin.readline

def main(args):
    txt = input().strip()
    txt = txt[:-1]
    # print(txt)
    result = 0
    if len(txt) % 2 == 1:
        txt = txt[:-1]
    while txt:
        l = len(txt)
        a_part = txt[:l//2]
        b_part = txt[l//2:]
        if a_part == b_part:
            result = l
            break
        txt = txt[:-2]
    print(result)

if __name__ == '__main__':
    main(sys.argv[1:])


S = list(input())

def check(i):
    if i % 2 == 0:
        return False

    first = S[:i // 2 + 1]
    tail = S[i // 2 + 1:i + 1]
    return "".join(first) == "".join(tail)

N = len(S) - 2
ans = -1
for i in range(N):
    if check(i):
        ans = i + 1
print(ans)


#coding=UTF-8

S=input()
Slen=len(S)

for idx in range(Slen-2,0-1,-2):
    T=S[0:idx]

    Tlen=len(T)
    #hantei
    for idy in range(0,Tlen//2,1):
        if T[idy] !=T[Tlen//2+idy]:
            break
    else:
        ans=idx
        break

print(ans)


def find_even(text):
    chars = list(text)
    tail_index = (len(chars) + 1) // 2
    pre = 0
    while tail_index > 0:
        tail_index -= 1
        pre = 0
        post = tail_index
        while chars[pre] == chars[post]:
            pre += 1
            post += 1
            if pre == tail_index:
                return 2 * tail_index
    raise("Error")

if __name__ == "__main__":
    # run_test(find_even, test_pair)
    print(find_even(raw_input()))


S = raw_input()
for i in range(1, len(S)):
    s = S[:-i]
    n = len(s)
    if (n % 2 == 0) and (s[:n/2] == s[n/2:]):
        print n
        break


s = input()

l = len(s)

for _ in range(200):
	s = s[:l-2]
	l = l - 2
	if s[:l//2] == s[l//2:]:
		print(l)
		break
	else:
		pass
else:
	print('no match')


if __name__ == "__main__":
    s = input()
    data = list(s)
    while len(data):
        data.pop()
        if len(data) % 2 == 0:
            half = int(len(data) / 2)
            if data[:half] == data[half:]:
                print(len(data))
                break


S = raw_input()
n = len(S)
for i in xrange(1, n):
    if (n - i)%2 > 0: continue
    T = S[:-i]
    if T[:len(T)/2] == T[len(T)/2:]:
        print n - i
        break


S = input()[:-2]

length = len(S)

while S[:int(length / 2)] != S[int(length / 2):]:
      S = S[:-2]
      length = len(S)

      if length == 0:
          breaek

print(length)


s = input()
l = len(s)
s = s[:l-1]
h = int(l / 2)

for i in range(len(s)):
    if l % 2 == 0:
        h = int(l / 2)
        a = s[:h]
        b = s[h:l]
        if a == b:
            print(l)
            break
    l -= 1


S = input()

def is_mirror_string(str):
    if len(str) % 2 != 0:
        return False
    else:
        i = int(len(str)/2)
        if str[0:i] == str[i:]:
            return True
        else:
            return False

def mirror_string_length(str):
    s = str[0:-1]
    while len(s):
        if is_mirror_string(s):
            return len(s)
        else:
            s = s[0:-1]
    return 0

print(mirror_string_length(S))


s = input()
ss = s[0:len(s)-1]

#print (ss)
for i in range(len(ss)):
    chrnum = int(len(ss))- i
    #print (chrnum)
    if chrnum % 2 == 0:
        #print (ss[0:int(chrnum/2)], end=' ')
        #print (ss[int(chrnum/2) : chrnum])
        if ss[0:int(chrnum/2)] == ss[int(chrnum/2) : chrnum]:
            print (chrnum)
            exit()


s = raw_input()

length = len(s)

for i in reversed(range(length)):
    s = s[:-1]
    l = len(s)
    tempa = l / 2
    temp = s
    s1 = temp[:tempa]
    s2 = temp[tempa:]

    if s1 == s2:
        print l
        break


a = raw_input()

while 1:
	a = a[:-1]
	if len(a) % 2 == 0:
		if a[:len(a) / 2] == a[len(a) / 2:]:
			print len(a)
			break


#!/usr/bin/env python

A,B=map(int,raw_input().split())
ans='Impossible'
if A%3==0:
    ans='Possible'
if B%3==0:
    ans='Possible'
if (A+B)%3==0:
    ans='Possible'

print ans


A, B = list(map(int, input().split(" ")))

if A % 3 == 0 or B % 3 == 0 or (A+B) % 3 == 0:
    print("Possible")
else:
    print("Impossible")


A,B=map(int,input().split())
print("Possible" if A%3==0 or B%3==0 or (A+B)%3==0 else "Impossible")


a, b = map(int, input().split())
c = a + b
if a % 3 == 0 or b % 3 == 0 or c % 3 == 0:
    print("Possible")
else:
    print("Impossible")


# coding: utf-8

A, B = tuple(map(int, input().split()))

print("Possible" if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0 else "Impossible")


A, B = map(int, input().split())

if (A+B) % 3 == 0 or A % 3 == 0 or B % 3 == 0:
    print("Possible")
else:
    print("Impossible")


A, B = map(int, input().split())

if (A % 3 == 0) or (B % 3 == 0) or ((A+B) % 3 == 0):
    print("Possible")
else:
    print("Impossible")


cookies = input().split(' ')
a, b = (int(cookies[0]), int(cookies[1]))

if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0: print('Possible')
else: print('Impossible')


list = input().rstrip().split()
A = int(list[0])
B = int(list[1])
if A%3 != 0:
    if B%3 != 0:
        if (A+B)%3 != 0:
            print("Impossible")
        else: print("Possible")
    else: print("Possible")
else: print("Possible")


sh = 3
a, b = map(int, input().split())
ab = a+b
if a % sh == 0 or b % sh == 0 or ab % sh == 0:
    print("Possible")
else:
    print("Impossible")


# Sharing Cokkies

A,B = list(map(int, input().split()))

if ( A%3==0 or B%3==0 or (A+B)%3==0 ):
    print("Possible")
else:
    print("Impossible")


A, B = map(int, input().split())
print ("Possible" if A %3 == 0 or B % 3 == 0 or (A+B) %3 == 0 else "Impossible")


m, n = map(int, input().split())
ans = (m + n) % 3
ans2 = m % 3
ans3 = n % 3
if ans == 0 or ans2 == 0 or ans3 == 0:
    print("Possible")
else:
    print("Impossible")


a,b = map(int, raw_input().split())
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
    print 'Possible'
else:
    print 'Impossible'


A,B = map(int, input().split())
if A%3 == 0 or B%3==0 or (A+B)%3 ==0:
    print('Possible')
else:
    print('Impossible')


b, c = map(int, raw_input().split())

if b%3==0 or c%3==0 or (b+c)%3==0:
  print 'Possible'
else:
  print 'Impossible'


a, b = map(int, input().split())
print("Possible" if (a+b)%3==0 or a%3==0 or b%3==0 else "Impossible")


from sys import stdin
a,b = map(int,stdin.readline().split())
ans = 'Impossible'
c = a+b
x = [a,b,c]
def ch(n):
 if n==0:
  return 0
 if n%3:
  return 0
 return 1
for i in x:
 if ch(i):
  ans = 'Possible'
print ans


a, b = list(map(int, input().split()))
if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:
    print("Possible")
else:
    print("Impossible")


a,b =(int (i) for i in input().split())
if a%3==0:
    print('Possible')
elif b%3==0:
    print('Possible')
elif (a+b)%3==0:
    print('Possible')
else:
    print('Impossible')


a, b = [int(x) for x in input().split()]
print('Possible' if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0 else 'Impossible')


A, B = map(int, input().split())
if A % 3 ==0 or B % 3 == 0 or (A+B) % 3 == 0:
    print('Possible')
else:
    print('Impossible')


A, B = [int(x) for x in input().split(" ")]
if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
    print("Possible")
else:
    print("Impossible")


A, B = list(map(int, input().split(" ")))

if (A % 3 != 0) and (B % 3 != 0) and ((A+B) % 3 != 0):
    print("Impossible")
else:
    print("Possible")


x = input().split(" ")
a = int(x[0])
b = int(x[1])

if ((a % 3 == 0) or (b % 3 == 0) or ((a+b) % 3 == 0) ):
    print("Possible")
else:
    print("Impossible")


x,y = map(int,input().split())
z = x+y
print('Possible' if x%3==0 or y%3==0 or z%3==0 else 'Impossible')


A, B = list(map(int, input().split()))

if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
    print("Possible")
else:
    print("Impossible")


input_line1 = map(int,raw_input().split(" "))
#input_line2 = map(int,raw_input().split(" "))
a = input_line1[0]
b = input_line1[1]
if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:
	print "Possible"
else:
	print "Impossible"


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

if a%3==0 or b%3==0 or (a+b)%3==0:
    print("Possible")
else :
    print("Impossible")


cookie = [int(x) for x in input().split()]
if cookie[0] % 3 == 0 or cookie[1] % 3 == 0 or (cookie[0] + cookie[1]) % 3 == 0:
    print("Possible")
else:
    print("Impossible")


a,b=map(int,input().split())
print("Possible"if (a%3)*(b%3)*((a+b)%3)==0 else "Impossible")


ans = ['Possible', 'Impossible']

def judge(a, b):
	if a % 3 == 0:
		return 0
	elif b % 3 == 0:
		return 0
	elif (a + b) % 3 == 0:
		return 0
	return 1

inpt = map(int, raw_input().split())
print ans[judge(inpt[0], inpt[1])]


a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
    print("Possible")
else:
    print("Impossible")


#!/usr/bin/env python
#-*- coding: utf-8 -*-

from collections import defaultdict
from math import factorial as f
from fractions import gcd as g

a, b = [int (i) % 3 for i in raw_input ().split ()]
if a: a = (a + b) % 3
if a: a = b
print ["Possible", "Impossible"][a != 0]


# coding: utf-8
# Here your code !

x=input()
a=int(x.split(" ")[0])
b=int(x.split(" ")[1])
if (a%3==0 or b%3==0 or (a+b)%3==0):
    print ("Possible")
else:
    print ("Impossible")


a, b = map(int, input().split(" "))

if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:
    print("Possible")
else:
    print("Impossible")


a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
  print("Possible")
else:
  print("Impossible")


A, B = map(int, input().split())

if A % 3 == 0:
    print('Possible')
elif B % 3 == 0:
    print('Possible')
elif (A + B) % 3 == 0:
    print('Possible')
else:
    print('Impossible')


a, b = map(int, raw_input().split())
if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
    print "Possible"
else:
    print "Impossible"


A, B = map(int, input().split())

if A%3==0 or B%3==0 or (A+B)%3==0:
    print("Possible")
else: print("Impossible")


a, b = map(int,input().split())
print("Possible" if(a+b)%3==0 or a%3==0 or b%3==0 else "Impossible")


def read(): return list(map(int, input().split()))

a, b = read()
print("Impossible" if a % 3 and b % 3 and (a + b) % 3 else "Possible")


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

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

if (a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0) and (a+b) > 0:
    print("Possible")
else:
    print("Impossible")


a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
    print('Possible')
else:
    print('Impossible')


def solution(a, b):
    total = a + b
    if total % 3 == 0:
        print('Possible')
    elif a % 3 == 0:
        print('Possible')
    elif b % 3 == 0:
        print('Possible')
    else:
        print('Impossible')

A, B = input().split(' ')
A, B = int(A), int(B)

solution(A, B)


x, y = map(int, input().strip().split())
e = x%3==0 or y%3==0 or (x+y)%3==0
print("Possible" if e else "Impossible")


l = list(map(int, input().split()))
a = l[0]+l[1]

if l[0] % 3 == 0:
    print("Possible")
elif l[1] % 3 == 0:
    print("Possible")
elif a % 3 == 0:
    print("Possible")
else:
    print("Impossible")


a, b = map(int, input().split())
if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:
    print("Possible")
else:
    print("Impossible")


A, B = map(int, input().split())
if(A%3==0):
    print("Possible")
elif(B%3==0):
    print("Possible")
elif((A+B)%3==0):
    print("Possible")
else:
    print("Impossible")


def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))

a,b = rli()
if(a % 3 == 0 or b % 3 == 0 or (a+b)%3 == 0):
    print("Possible")
else:
    print("Impossible")


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

l = map(int, raw_input().split())
A = l[0]
B = l[1]

if A%3 == 0 or B%3 == 0 or (A+B)%3 == 0:
    print('Possible')
else:
  print('Impossible')


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

A, B = [int(x) for x in input().split()]

if A % 3 == 0:
    print ("Possible")
elif B % 3 == 0:
    print("Possible")
elif (A + B) % 3 == 0:
    print("Possible")
else:
    print("Impossible")


def sharing_cookies():
	A, B = map(int, raw_input().split(" "))
	if A%3==0 or B%3==0 or (A+B)%3==0:
		print "Possible"
	else:
		print "Impossible"

if __name__ == "__main__":
	sharing_cookies()


str_cookies_num = input()
cookies_num = str_cookies_num.split()
cookies_A = int(cookies_num[0])
cookies_B = int(cookies_num[1])

if (cookies_A + cookies_B) % 3 == 0:
    print("Possible")
elif cookies_A % 3 == 0:
    print("Possible")
elif cookies_B % 3 == 0:
    print("Possible")
else:
    print("Impossible")


A, B = [int(i) for i in input().split()]

if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
    print('Possible')
else:
    print('Impossible')


a, b = map(int, input().split(" "))

if (a+b)%3 == 0:
    print("Possible")
elif a%3 == 0:
    print("Possible")
elif b%3 == 0:
    print("Possible")
else:
    print("Impossible")


# -*- coding: utf-8 -*-
a, b = map(int, raw_input().split())
if a % 3 == 0:
    print 'Possible'
elif b % 3 == 0:
    print 'Possible'
elif (a + b) % 3 == 0:
    print 'Possible'
else:
    print 'Impossible'


def mainA():
    A, B = map(int, input().split())
    print('Possible' if A%3==0 or B%3==0 or (A+B)%3==0 else 'Impossible')

mainA()


A,B = map(int,input().split())

if (A+B)%3==0 or A%3==0 or B%3==0:
    print("Possible")

else:
    print("Impossible")


a,b=map(int,input().split())
if a%3==0:
  print("Possible")
elif b%3==0:
  print("Possible")
elif (a+b)%3==0:
  print("Possible")
else:
  print("Impossible")


a, b = map(int, input().split())
if (a%3 == 0) or (b%3 == 0) or ((a+b)%3 == 0):
    print('Possible')
else:
    print('Impossible')


A= (input().split())
if int(A[0]) % 3 == 0 or int(A[1]) % 3 == 0 or (int(A[0]) + int(A[1])) % 3 == 0:
    print("Possible")
else:
    print("Impossible")


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

import re

a, b = map(int, re.split('\s', raw_input()))

if (a % 3 == 0) or (b % 3 == 0) or ((a+b) % 3 == 0):
        print "Possible"
else:
        print "Impossible"


A, B = map(int, raw_input().split())

if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
    print "Possible"
else:
    print "Impossible"


def main():
    A, B = list(map(int, input().strip().split()))
    if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
        print("Possible")
    else:
        print("Impossible")

if __name__ == '__main__':
    main()


A,B = map(int, input().split())
if A%3==0 or B%3==0 or (A+B)%3==0:
    print("Possible")
else:
    print("Impossible")


A, B = map(int, input().split())
C = A + B

if A % 3 == 0 or B % 3 == 0 or C % 3 == 0:
	print('Possible')
else:
	print('Impossible')


a,b = list(map(int,input().split()))
c = a + b
if (a % 3 == 0):
    print("Possible")
elif (b % 3 == 0):
    print("Possible")
elif (c % 3 == 0):
    print("Possible")
else:
    print("Impossible")


def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))

a,b = rli()
if(a % 3 == 0 or b % 3 == 0 or (a+b)%3 == 0):
    print("Possible")
else:
    print("Impossible")


a, b = map(int, input().split())
if a % 3 == 0 or b % 3 ==0 or (a + b) % 3 == 0:
    print('Possible')
else:
    print('Impossible')


#Python

l = map(int, raw_input().split())

A=l[0]
B=l[1]
#print A
#print B

if A%3==0 or B%3==0 or (A+B)%3==0:
	print 'Possible'
else:
	print 'Impossible'


print((lambda a, b: (not a%3 or not b%3 or not (a + b) % 3) and "Possible" or "Impossible")(*map(int, input().split())))


a,b=[int(i) for i in input().split()]
if (a%3==0 or b%3==0 or (a+b)%3==0):
    print ("Possible")
else : print ("Impossible")


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

if a%3==0 or b%3==0 or (a+b)%3==0:
    print("Possible")
else:
    print("Impossible")


# -*- coding:utf-8 -*-
A, B = map(int, input().split())
if A%3 == 0 or B%3 == 0 or (A+B)%3 == 0:
    print("Possible")
else:
    print("Impossible")


a,b = map(int, input().split())
print('Possible' if a%3==0 or b%3==0 or (a+b)%3==0 else 'Impossible')


a, b = map(int, input().split())
if (a + b) % 3 == 0:
    print("Possible")
    exit()
elif a % 3 == 0 or b % 3 == 0:
    print("Possible")
else:
    print("Impossible")


A, B = list(map(int ,input().split()))
if(A%3 !=0 and B%3 != 0 and (A+B) %3 != 0):
    print("Impossible")
else:
    print("Possible")


N = input().split()

A = int(N[0])
B = int(N[1])

if A%3 == 0:
    print("Possible")
elif B%3 == 0:
    print("Possible")
elif (A+B)%3 == 0:
    print("Possible")
else:
    print("Impossible")


if __name__ == "__main__":
    a,b = map(int, input().split())
    if a >= 3 and a % 3 == 0:
        print ("Possible")
        exit()
    if b >= 3 and b % 3 == 0:
        print ("Possible")
        exit()
    if (a + b) >= 3 and (a + b) % 3 == 0:
        print ("Possible")
        exit()
    print ("Impossible")


a,b = map(int,input().split())
if (a + b) % 3 == 0 or a % 3 == 0 or b % 3 == 0:
   print("Possible")
else:
   print("Impossible")


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

#すぬけくんは 3 匹のヤギにクッキーを渡したいです。
#すぬけくんは A 枚のクッキーが入った缶と、B 枚のクッキーが入った缶を持っています。
#すぬけくんは A,B,A+B のいずれかの枚数のクッキーをヤギたちに渡すことができます。
#3 匹のヤギが同じ枚数ずつ食べられるようにクッキーを渡すことが可能かどうか判定してください。
#3 匹のヤギが同じ枚数ずつ食べられるようにクッキーを渡すことが可能ならば Possible と、
#そうでなければ Impossible と出力せよ。

A = input().split()
#A = [3, 3]
x = int(A[0])
y = int(A[1])

if x % 3 ==0:
    print("Possible")

elif y % 3 ==0:
    print("Possible")

elif (x + y) % 3 ==0:
    print("Possible")

else:
    print("Impossible")


a,b = map(int,input().split())
msg = ""
if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
 msg = 'Possible'
else :
 msg  = 'Impossible'
print(msg)


A, B = list(map(int, input().split()))

if A == 0 and B == 0:
    print("Impossible")
elif A % 3 == 0 or B % 3 == 0 or (A+B) % 3 == 0:
    print("Possible")
else:
    print("Impossible")


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

if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:
    print('Possible')
else:
    print('Impossible')


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

jud=False

if a%3==0:
    jud=True
elif b%3==0:
    jud=True
elif (a+b)%3==0:
    jud=True
else:
    jud=False

if jud==True:
    print("Possible")
else:
    print("Impossible")


# coding: utf-8
# Here your code !
a=input()
b=a.split(" ")
A=int(b[0])
B=int(b[1])

C=A+B
if C%3==0 or A%3==0 or B%3==0:
    print("Possible")
else:
    print("Impossible")


a, b = map(int, raw_input().split())
print "Possible" if (a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0) else "Impossible"


import sys
a, b = map(int, sys.stdin.readline().split())
print ["Impossible", "Possible"][a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0]


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

if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:
    print("Possible")
else:
    print("Impossible")


ab = input().split(' ')
#print(ab)
if int(ab[0])  % 3 == 0 or int(ab[1]) % 3 ==0   or (int(ab[1])+ int(ab[0])) % 3 == 0:
    ans  = 'Possible'

else:
    ans ='Impossible'

if (int(ab[0]) + int(ab[1])) <= 3:
    ans= 'Impossible'
print (ans)


n,m=map(int,raw_input().split())
print "Possible" if n%3==0 or m %3==0 or (n+m)%3==0 else "Impossible"


a,b=map(int,input().split())
c=a+b

if a%3==0 or b%3==0 or c%3==0: print("Possible")
else: print("Impossible")


a, b = map(int, input().split())
print('Impossible' if a % 3 and b % 3 and (a + b) % 3 else 'Possible')


#!/usr/bin/env python
# -*- conding: utf-8 -*-

raw = raw_input()
A = int(raw.split()[0])
B = int(raw.split()[1])

if(A%3==0 or B%3==0 or (A+B)%3==0):
    print "Possible"
else:
    print "Impossible"


A , B = map(int, input().split())
if A + B <  3:
    print("Impossible")

elif A%3 == 0 or B%3 == 0 or (A+B)%3 ==0 :
    print("Possible")

else:
    print("Impossible")


m, n = map(int, input().split())
ans = (m + n) % 3
ans2 = m % 3
ans3 = n % 3
if ans == 0 or ans2 == 0 or ans3 == 0:
    print("Possible")
else:
    print("Impossible")


Imp = list(map(int, input().split()))
A = Imp[0]
B = Imp[1]
re = 0
if A % 3 == 0:
    re = 1
if B % 3 == 0:
    re = 1
if (A+B) % 3 == 0:
        re = 1

if re ==1:
    print("Possible")
else:
    print("Impossible")


A, B = list(map(int, input().split()))
if A % 3 == 0 or B % 3 == 0 or (A+B) % 3 == 0:
	print("Possible")
else:
	print("Impossible")


a,b=map(int,input().split())
c=a + b

if  a%3==0 or b%3==0 or c%3==0: print("Possible")
else: print("Impossible")


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

def check(a, b):
    if a % 3 == 0:
        return 1
    elif b % 3 == 0:
        return 1
    elif (a + b) % 3 == 0:
        return 1
    else:
        return 0

def main():
    if check(a, b) == 1:
        print("Possible")
    else:
        print("Impossible")

main()


A , B = map(int, input().split())
#print(A, B)
if (A%3==0 or B%3 == 0 or (A+B) % 3 == 0):
    print("Possible")
else:
    print("Impossible")


a=list(map(int,input().split()))
if a[0]%3==0 or a[1]%3==0 or (a[0]+a[1])%3==0:
    print("Possible")
else:
    print("Impossible")


a,b=map(int,input().split())
c = a+b
if a%3==0 or b%3==0 or c%3==0:
    print("Possible")
else:
    print("Impossible")


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

if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:
    print('Possible')
else:
    print('Impossible')


a, b = [int(i) for i in input().split()]
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
    print('Possible')
else:
    print('Impossible')


if __name__ == '__main__':
    lis = list(map(int, input().split()))
    A = lis[0]
    B = lis[1]

    if (A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0):
        print("Possible")
    else:
        print("Impossible")


# -*- coding: utf-8 -*-
"""
http://abc067.contest.atcoder.jp/tasks/abc067_a

"""
import sys
from sys import stdin
input = stdin.readline

def main(args):
    A, B = map(int, input().split())
    if (A+B) % 3 == 0 or A % 3 == 0 or B % 3 == 0:
        print('Possible')
    else:
        print('Impossible')

if __name__ == '__main__':
    main(sys.argv[1:])


t = raw_input().split()
a = int(t[0])
b = int(t[1])
if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
	print('Possible')
else:
	print("Impossible")


# coding=utf-8
a,b = map(int, raw_input().split())

if (a + b) %3 == 0:
    print("Possible")
elif a % 3 == 0:
    print("Possible")
elif b % 3 == 0:
    print("Possible")
else:
    print("Impossible")


A, B = map(int, input().split())

if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
    print('Possible')
else:
    print('Impossible')


A, B = [int(n) for n in input().split()]
if A%3==0 or B%3==0 or (A+B)%3==0:
  print("Possible")
else:
  print("Impossible")


a,b = map(int,input().split())
if a % 3 == 0:
	print('Possible')
elif b % 3 == 0:
	print('Possible')
elif (a + b) % 3 == 0:
	print('Possible')
else:
	print('Impossible')


A, B = map((int), input().split())

if(A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0 ):
    print("Possible")
else:
    print("Impossible")


A, B = map(int, raw_input().split())

C = A + B

if A % 3 == 0:
    print "Possible"
elif B % 3 == 0:
    print "Possible"
elif C % 3 == 0:
    print "Possible"
else:
    print "Impossible"


a, b = map(int, input().split(" "))
if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:
  print("Possible")
else:
  print("Impossible")


a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
    print("Possible")
else:
    print("Impossible")


c= [int (i) for i in input().split()]
if sum(c)%3==0 or c[0]%3==0 or c[1]%3 ==0:
	print('Possible')
else: print('Impossible')


A,B=map(int,input().split())
if (A%3==0 or B%3==0 or (A+B)%3==0):
 print ('Possible')
else:
 print('Impossible')


c, d = map(int, input().split())
ans = 0

if(c % 3 == 0) :
    ans = 1
elif(d % 3 == 0) :
    ans = 1
elif((c + d) % 3 == 0) :
    ans = 1

if (ans == 1) :
    print ('Possible')
else :
    print ('Impossible')


import sys

def main():
    line = sys.stdin.readline()
    lst = line.split()
    a = int(lst[0])
    b = int(lst[1])

    if (a % 3 == 0) or (b % 3 == 0) or ((a+ b) % 3 == 0 ):
        print("Possible")
    else:
        print("Impossible")

    return 0

if __name__ == '__main__':
    sys.exit(main())


s = input().split()
s = [int(i) for i in s]
a = s[0]
b = s[1]

if a % 3 == 0 : print("Possible")
elif b % 3 == 0 : print("Possible")
elif (a + b) % 3 == 0 : print("Possible")
else : print("Impossible")


A, B = list(map(int, input().split()))

if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
    print("Possible")
else:
    print("Impossible")


a, b = map(int, raw_input().split())

if a % 3 == 0 or b % 3 == 0 or (a+b)%3==0:
    print("Possible")
else:
    print("Impossible")


# -*- coding: utf-8 -*-
import sys

A, B = map(int, input().split())

C = A + B

if A%3 == 0:
    print('Possible')
elif B%3 == 0:
    print('Possible')
elif C%3 == 0:
    print('Possible')
else:
    print('Impossible')


#!/usr/bin/python

import sys

def main(argv):
    for line in sys.stdin:
        A, B = map(lambda x: int(x), line.split(" ", 2))
        if (A % 3) == 0 or (B % 3) == 0 or ((A+B) % 3) == 0:
            print("Possible")
        else:
            print("Impossible")

if __name__ == "__main__":
    main(sys.argv)


#!usr/bim/python
#! -*- coding: utf-8 -*-

a_b = raw_input()
a_b = a_b.split()
a = a_b[0]
b = a_b[1]
a = int(a)
b = int(b)

status = 0

if a % 3 == 0:
    status = 1
elif b % 3 == 0:
    status = 1
elif (a + b) % 3 == 0:
    status = 1

if status == 0:
    print "Impossible"
else:
    print "Possible"


a,b = map(int,input().split())
#print(a,b)
#c = 0
if a%3 == 0 or b%3 == 0 or (a+b)%3 ==0:
    print('Possible')
else:
    print('Impossible')


a, b = map(int, input().split())
if a % 3 == 0 or b % 3 == 0 or (a + b )%3 == 0:
    print('Possible')
else:
    print('Impossible')


n,k = [int(i) for i in input().split()]
print(-sum(sorted([-int(i) for i in input().split()])[:k]))


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

H.sort(reverse=True)

A=H[0:K]
B=sum(A)

print(B)


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

lenghths.sort(reverse=True)
answer = sum(lenghths[0:K])
print(answer)


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

L.sort()

print(sum(L[-K:]))


N, K = map(int, input().split())
l = list(map(int, input().split()))
L = sorted(l, reverse = True)
ans = 0
for i in range(K):
	ans += L[i]

print(ans)


n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
a.sort()
a.reverse()
print(sum(a[:k]))


n,k=map(int,input().split())
l=[int(x) for x in input().split()]
print(sum(sorted(l)[n-k:]))


#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

input_line = sys.stdin.readline().split(' ')
n = int(input_line[0])
k = int(input_line[1])

input_line = sys.stdin.readline().split(' ')
l_list = list(map(int, input_line))

l_list.sort(reverse=True)

l = 0
for i in range(0, k):
	l += l_list[i]

print(l)


import sys
n, k = map(int, sys.stdin.readline().split())
a = sorted(map(int, sys.stdin.readline().split()))

print sum (a[n - k:])


def main():
    N, K = list(map(int, input().strip().split()))
    ls = list(map(int, input().strip().split()))
    k_total = sum(sorted(ls, reverse=True)[:K])
    print(k_total)

if __name__ == '__main__':
    main()


N, K = map(int, input().split())
L = list(map(int, input().split()))
L.sort(reverse=True)

ans = sum(L[:K])
print(ans)


# -*- coding:utf-8 -*-
import itertools
import numpy as np

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

ans = 0
for i in range(K):
    max_i = np.argmax(l)
    ans += l[max_i]
    l = np.delete(l,max_i)

print(ans)


def solution(n, k, l_list):
    l_list.sort(reverse=True)
    result = sum(l_list[:k])
    return result

N, K = [int(value) for value in input().split(' ')]
l_list = [int(value) for value in input().split(' ')]
print(solution(N, K, l_list))


def solve():  # 068B - Snake Toy
    N, K = [int(x) for x in input().split(" ")]
    l = [int(x) for x in input().split(" ")]
    l.sort(reverse=True)
    print(sum(l[:K]))

solve()


# -*- coding: utf-8 -*-
"""
http://abc067.contest.atcoder.jp/tasks/abc067_b

"""
import sys
from sys import stdin

input = stdin.readline

def main(args):
    N, K = map(int, input().split())
    rods = [int(x) for x in input().split()]
    rods.sort()
    snake = rods[-K:]
    print(sum(snake))

if __name__ == '__main__':
    main(sys.argv[1:])


from sys import stdin
n,k = map(int,stdin.readline().split())
a = map(int,stdin.readline().split())
a.sort()
a.reverse()
print sum(a[:k])


n,k=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
l.sort()
a=0
for i in range(k):
  a+=l[n-1-i]
print(a)


N, K = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = 0
for i in range(K):
    ans += l[i]
print(ans)


n, k = map(int, input().split())

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

l.sort()
l.reverse()

print(sum(l[0:k]))


N_K = map(int, raw_input().split())

l = map(int, raw_input().split())
l.sort()
l.reverse()

ans = 0

for i in range(N_K[1]):
    ans += int(l[i])

print ans


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

l_list.sort(reverse=True)
print(sum(l_list[:K]))


N, K = input().split()
l = input().split()
l = list(map(int, l))
l.sort(reverse=True)

sum = 0
for i in range(int(K)):
  sum += l[i]

print(sum)


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

l.sort(reverse=True)

A=0

for i in range(K):
    A+=l[i]

print(A)


def read(): return list(map(int, input().split()))

n, k = read()
l = read()
print(sum(sorted(l)[::-1][:k]))


# coding: utf-8

n, k = map(int, raw_input().split())
l = map(int, raw_input().split())

l.sort()
print sum(l[-k:])


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

import re

n, k = map(int, re.split('\s', raw_input()))
l = map(int, re.split('\s', raw_input()))
ans = 0

l.sort()
l.reverse()
for i in range(0,k):
        ans += l[i]

print ans


N,K=map(int,input().split())
l=sorted(map(int,input().split()),reverse=True)
print (sum(l[:K]))


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

l = list(map(int, input().split(" ")))

sorted_l = sorted(l)[::-1]

print(sum(sorted_l[:K]))


n,k = map(int, input().split())
long = [int(i) for i in input().split()]
long = sorted(long, reverse = True)
print(sum(long[0:k]))


a = list(map((int),input().split(' ')))

N = a[0]
K = a[1]
sub = N - K

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

for i in range(sub):
    b.pop(b.index(min(b)))

print(sum(b))


N, K = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
ans = 0

for i in range(K):
	ans += max(l)
	l.pop(l.index(max(l)))

print(ans)


n, k = map(int, input().split())
print(sum((sorted(map(int, input().split())))[n-k:n]))


N, K = [int(i) for i in input().split()]

l = [int(j) for j in input().split()]

l = sorted(l)

ans = 0
for k in range(N-K, N, 1):
    ans += l[k]

print(ans)


n, k = map(int,input().split())
l = list(map(int,input().split()))

l.sort()
ans = 0
for i in range(k):
    ans += l[-i - 1]

print(ans)


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

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

L.sort(reverse=True)
ans = 0
for i in range(K):
    ans += L[i]
print(ans)


#!/usr/bin/env python

N,K=map(int,raw_input().split())
l=map(int,raw_input().split())
l.sort()
print sum(l[len(l)-K:len(l)])


n, k =(int (i) for i in input().split())
l=[int(i) for i in input().split()]
l.sort()
sum=0
for i in range(0,k):
    sum += l.pop()

print(sum)


N, K = list(map(int, input().split()))
L = list(map(int, input().split()))
L.sort()
print(sum(L[-1:-K-1:-1]))


N, K = map(int,input().split())
L = list(map(int, input().split()))
L.sort()
print(sum(L[N-K:]))


N, K = map(int, raw_input().split())
l = list(map(int, raw_input().split()))

l.sort(reverse=True)

print sum(l[:K])


N, K = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
a.reverse()
sum = 0
for i in range(K):
    sum += a[i]
print(sum)


#!usr/bim/python
#! -*- coding: utf-8 -*-

n_k = raw_input()
n_k = n_k.split()
n_k = map(int,n_k)
n = n_k[0]
k = n_k[1]

l = raw_input()
l = l.split()
l = map(int,l)

ans = 0
i = 0
while i < k:
    max_len = max(l)
    ans += max_len
    l[l.index(max_len)] = 0
    i += 1

print ans


n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort(reverse = True)
ans = 0
for i in xrange(k):
    ans += a[i]
print ans


N, K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
ans = 0

l.sort(reverse=True)
for i in range(K):
	ans += l[i]

print(ans)


import sys

# sys.stdin = open('b1.in')

def read_int_list():
    return list(map(int, input().split()))

def read_str_list():
    return input().split()

def read_int():
    return int(input())

def read_str():
    return input()

def main():
    n, k = read_int_list()
    l = read_int_list()
    l.sort()
    res = sum([i for i in l[-k:]])
    print(res)

main()


N, K = map(int, input().split())
lens = [int(e) for e in input().split()]
lens.sort()
lens.reverse()

print(sum(lens[:K]))


n,m=map(int,raw_input().split())
s=raw_input().split()
a=[]
t=[0 for i in range(n)]
for i in range(n):
    a.append(int(s[i]))
sum=0
a=sorted(a)
for j in range(n-1,n-m-1,-1):
    sum=sum+a[j]
print sum


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

l.sort()
l.reverse()

sum = 0
for i in range(K):
	sum += l[i]
print(sum)


N, K = map(int, raw_input().split())
l = sorted(map(int, raw_input().split()))
print sum(l[-K:])


inpt = map(int, raw_input().split())
n = inpt[0]
k = inpt[1]
lst = map(int, raw_input().split())
lst.sort()
ans = 0
for i in range(0, k):
	ans += lst[-1-i]
print ans


n, k = map(int, input().split())
l = list(map(int, input().split()))

lsort = sorted(l, reverse=True)

lsum = 0
for i in range(k):
    lsum = lsum + lsort[i]
print(lsum)


sum = 0
N, K = map(int, input().split())
l = map(int, input().split())
#print(l)
sort_l = sorted(l, reverse = True)
#print(sort_l)
for i in range(0,K):
    sum += sort_l[i]

print(sum)


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

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

def main(K):
    ans = 0
    L.sort()
    L.reverse()
    i = 0
    while i < K:
        ans += L[i]
        i += 1
    return ans

print(main(K))


N, K = map(int, input().split())
l = map(int, input().split())
print(sum(sorted(l, reverse=True)[:K]))


import numpy as np

nk = input().split(' ')
n, k = (int(nk[0]), int(nk[1]))
l = [int(num) for num in input().split(' ')]
max = 0
for _ in range(k):
    m = np.array(l).max()
    max += m
    l.remove(m)
print(max)


import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    n,k = LI()
    a = sorted(LI(),reverse=True)

    return sum(a[:k])

print(main())


N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(key=lambda x: -x)
ans = 0
for i in range(K):
    ans += l[i]
print(ans)


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

lenghths.sort(reverse=True)
answer = sum(lenghths[0:K])
print(answer)


# encoding:utf-8

def main():
	N, K = list(map(int, input().split()))
	len_bar = list(map(int, input().split()))
	len_bar.sort()
	adapt_bar = len_bar[N-K:]
	print(sum(adapt_bar))

if __name__ == '__main__':
	main()


N, K = map(int, input().split())
L = [int(n) for n in input().split()]
sort = sorted(L, reverse=True)
length = 0
for i in range(K):
    length += sort[i]
print(length)


a,b = map(int,input().split())
c = list(map(int,input().split()))
d = 0
for x in range(b):
    cc = max(c)
    d += cc
    c.remove(cc)
print(d)


def mainB():
    N, K = map(int, input().split())
    l =  list(map(int, input().split()))
    l = sorted(l)[::-1]
    ans = 0
    for i in range(K):
        ans += l[i]
    print(ans)

mainB()


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

l.sort(reverse=True)
for num in range(K):
    res = res + l[num]
print(str(res))


sticks_canJoinNum = input()
str_stickLength = input()

sticks_num = int(sticks_canJoinNum.split()[0])
num_canJoin = int(sticks_canJoinNum.split()[1])
stick_list = [int(i) for i in str_stickLength.split()]

stick_list.sort(reverse=True)
max_length = sum(stick_list[:num_canJoin])
print(max_length)


Imp = list(map(int, input().split()))
Blist = list(map(int, input().split()))
Blist.sort()

out = 0
for i in range(Imp[1]):
    out += Blist[-(i+1)]

print(out)


n,k = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
length = 0
for i in range(k):
	length += l[n-1-i]
print(length)


m, n = map(int, input().split())
M = list(map(int, input().split()))
M.sort()
M.reverse()
A = []
for i in range(n):
    A.append(M[i])
print(sum(A))


n, k = map(int, input().split())
len_list = list(map(int, input().split()))

len_list.sort(reverse=True)

print(sum(len_list[:k]))


N,K  = map(int, raw_input().split())
l =  map(int, raw_input().split())
l.sort(reverse=True)
sum = 0
for i in range(K):
    sum += l[i]
print(sum)


N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
print(sum(l[:K]))


N,K = map(int, input().split())
L = list(map(int, input().split()))
L = sorted(L)[::-1]
print(sum(L[:K]))


# -*- coding:utf-8 -*-
N, K = map(int, input().split())
l = sorted(list(map(int, input().split())), reverse = True)
ans = 0
for tmp in range(K):
    ans += l[tmp]
print(ans)


N,K = [int(i) for i in input().split(" ")]
l = [int(i) for i in input().split(" ")]
l.sort()
print(sum(l[N-K:N]))


n, k = map(int, input().split())
print(sum(list(sorted(map(int, input().split()), reverse=True))[:k]))


N, K = [int(n) for n in input().split()]
l = [int(n) for n in input().split()]

l.sort(reverse = True)

print(sum(l[:K]))


a,b = map(int,input().split())
n = list(map(int,input().split()))
n.sort()
print(sum(n[-b:]))


n,k = map(int, raw_input().split())
l = map(int, raw_input().split())
l.sort()
s = 0
for i in range(n-k, n):
    s += l[i]
print s


A = input().split()

N = int(A[0])
K = int(A[1])

A = input().split()
l = []

for n in range(N):
    l.append(int(A[n]))

l.sort(reverse=True)
sum=0
for i in range(K):
    sum = sum + l[i]
print(sum)


#ABC067B

n,k=map(int,raw_input().split())
l=map(int,raw_input().split())
l=sorted(l,reverse=True)
res=0
for i in xrange(k):
 res+=l[i]
print res


if __name__ == "__main__":
    N, K = list(map(int, input().split()))
    data = list(map(int, input().split()))
    data.sort(reverse = True)
    result = sum(data[:K])
    print(result)


N,K = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
l.sort()
l1 = 0
for i in range(K):
    l1 = l1+l[-1-i]
print(l1)


n, k = map(int, input().split(" "))

l = list(map(int, input().split(" ")))
l.sort()

sum = 0
for i in range(n-k, n):
    sum = sum + l[i]

print(sum)


from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10

def main():
    N, K = map(int, input().split())
    l_list = list(sorted(list(map(int, input().split()))))
    print(sum(l_list[-K:]))

if __name__ == '__main__':
    main()


def Q2(x):
    N, K = x[0][0], x[0][1]
    lst = x[1][:]
    lst = sorted(lst)[::-1]
    return sum(lst[:K])

l = [int(i) for i in input().split()]
m = [int(i) for i in input().split()]
n = [l,m]
print(Q2(n))


# -*- coding: utf-8 -*-
import sys

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

l.sort()
s = 0
for i in range(K):
    s += l[N-K+i]

print(s)


n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
cnt = 0
ans = 0
l.sort()
for i in reversed(l):
    if cnt < k:
        ans += i
        cnt += 1
    else:
        break
print(ans)


# coding: utf-8
# Here your code !
a=input()
b=a.split(" ")
N=int(b[0])
K=int(b[1])
ans=[]
c=input()
l=c.split(" ")
l1=map(int,l)
l2=list(l1)
for w in range(K):
    ans.append(max(l2))
    max_idx = l2.index(max(l2))
    del l2[max_idx]
print(sum(ans))


c, d = map(int, input().split())
ans = 0

a = [int(i) for i in input().split()]
a.sort()

for i in range(d) :
    ans = ans + a[c-1-i]

print (ans)


N,K=[int(i) for i in input().split()]
L=[int(i) for i in input().split()]
L.sort()
L.reverse()
hebi=0
for i in range(K):
 hebi=hebi+L[i]
print(hebi)


n, k =(int (i) for i in input().split())
l=[int(i) for i in input().split()]
l.sort()
sum=0
for i in range(0,k):
    sum += l.pop()

print(sum)


def main():
    N, K = map(int, input().split())
    L = list(map(int, input().split()))
    L.sort(reverse=True)

    print(sum(L[:K]))

if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()


n, k = map(int, raw_input().split())

l = map(int, raw_input().split())

l.sort()
l.reverse()

ans = 0

for i in range(k):
    ans += l[i]

print ans


ans = 0
n, k = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
lst.reverse()
for i in range(k):
    ans += lst[i]
print(ans)


n, k = map(int, input().split())

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

l.sort()
l.reverse()
ans = 0
for i in range(k):
    ans += l[i]

print(ans)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)

def main():
    n, k = map(int, input().split())
    ls = list(map(int, input().split()))

    ls.sort(reverse=True)
    ans = sum(ls[:k])
    print(ans)

if __name__ == "__main__": main()


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

a.sort(reverse=True)
ans=sum(a[:K])
print(ans)


# coding: utf-8

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

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

print(sum(sorted(l, reverse = True)[0:K]))


# -*- coding: utf-8 -*-
n, k = map(int, raw_input().split())
l = map(int, raw_input().split())
l.sort(reverse=True)

a = 0
for i in range(k):
    a = a + l[i]

print a


N, K = list(map(int, input().split()))
l = [int(0)] * N
l = list(map(int, input().split()))
l.sort()
sum=0
for i in range(K):
    sum+=l[N-1-i]
print(sum)


n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = 0
for i in range(k):
    ans += l[i]
print(ans)


N,K=map(int,input().split())
l=list(map(int,input().split()))
S=0
for i in range(K):
    S+=max(l)
    l.remove(max(l))
print(S)


N,K=map(int,input().split())
L=list(map(int,input().split()))
L.sort(reverse=1)
ans=0
for i in range(K):
  ans+=L[i]
print(ans)


m, n = map(int, input().split())
M = list(map(int, input().split()))
M.sort()
M.reverse()
A = []
for i in range(n):
    A.append(M[i])
print(sum(A))


n, k = map(int, input().split())
ls = sorted(list(map(int, input().split())))
print(sum(ls[-k:]))


N,K = map(int, input().split())
src = list(map(int, input().split()))
src.sort()
print(sum(src[-K:]))


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

lengths = sorted(lengths)
result = 0
for i in range(len(lengths)-1,len(lengths)-1-K,-1):
    result += lengths[i]
print(result)


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

l.sort(reverse=True)
print(sum(l[0:K]))


n, k = map(int, input().split())
l = list(map(int, input().split()))
print(sum(sorted(l, reverse=True)[:k]))


i = input().split()
l = list(map(int, input().split()))
n = int(i[0])
k = int(i[1])

l.sort(reverse = True)
ans = 0

for i in range(k):
    ans += l[i]
print(ans)


import sys

def main():
    line = sys.stdin.readline()
    lst = line.split()
    n = int(lst[0])
    k = int(lst[1])

    line = sys.stdin.readline()
    lst = line.split()
    l_lst = sorted([int(l) for l in lst], reverse=True)

    print(sum(l_lst[:k]))

    return 0

if __name__ == '__main__':
    sys.exit(main())


n, k = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
l.sort()
l.reverse()
sum = 0
for m in range(k):
    sum += l[m]
print(sum)


list = input().rstrip().split()
N = int(list[0])
K = int(list[1])
list2 = input().rstrip().split()
a = []
for i in range(N):
    a = a + [int(list2[i])]
a.sort()
sum = 0
for i in range(K):
    sum = sum + a[N-1-i]
print(sum)


n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort(reverse = True)
print sum(a[0:k])


n, k = map(int, input().strip().split(' '))
arr = sorted(list(map(int, input().strip().split(' '))))
print(sum(arr[-k:]))


N, K = map((int), input().split())
l = [int(item) for item in input().split()]

l.sort(reverse = True)

s = 0
for i in range(K):
    s += int(l[i])

print(s)


#!/usr/bin/python

import sys

def main(argv):
    N, K = map(lambda x: int(x), sys.stdin.readline().split(" ", 2))
    while N and K:
        L = map(lambda x: int(x), raw_input().split(" ", N))
        print(sum(sorted(L)[-K:]))

        line = sys.stdin.readline()
        if line:
            N, K = map(lambda x: int(x), line.split(" ", 2))
        else:
            N = None
            K = None

if __name__ == "__main__":
    main(sys.argv)


(N, K) = map(int, input().split(" "))
a = map(int, input().split())
sa = sorted(a)
leng = sum(sa[:-(K+1):-1])
print(leng)


#!/usr/bin/env python
# -*- coding: utf8 -*-

N, K=map(int, raw_input().split())
l = map(int, raw_input().split())

l.sort(reverse=True)
SUM = 0
for i in range(K):
    SUM += l[i]

print SUM


n, k = [int(x) for x in input().split()]
l = [int(y) for y in input().split()]

l.sort()

print(sum(l[-k:]))


# スペース区切りの整数の入力
N, K = map(int, input().split())

l = [int(i) for i in input().split()]
l.sort(reverse=True)

ans = 0
for i in range(K):
	ans += l[i]

print(ans)


n,k=map(int,input().split())
l = list(map(int,input().split()))
l.sort(reverse=True)

print(sum(l[:k]))


n, k = map(int, input().split(" "))
l = map(int, input().split(" "))

print(sum(sorted(l)[-k:]))


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

#すぬけくんは N 本の棒を持っています。 i 番目の棒の長さは li です。
#すぬけくんは K 本の棒を選んでつなげて、ヘビのおもちゃを作りたいです。
#ヘビのおもちゃの長さは選んだ棒たちの長さの総和で表されます。
#ヘビのおもちゃの長さとしてありうる長さのうち、最大値を求めなさい。

A = input().split()
B = input().split()
#A = [5, 3]
#B = [1, 2, 3, 4, 5]
#A = [15, 14]
#B = [50, 26, 27, 21, 41, 7, 42, 35, 7, 5, 5, 36, 39, 1, 45]

N = int(A[0])
K = int(A[1])

C = []

for i in range(N):
    C.append(int(B[i]))

D = sorted(C)

ans = 0

for i in range(K):
    x = N - i -1
    ans = ans + D[x]

print(ans)


if(__name__ == "__main__"):
    N, K =[int(i) for i in input().split()]
    a = [int(i) for i in input().split()]
    #print(a,b)

    maxlist = a[:K]
    #print(maxlist)
    for i in range(K,N):
        if(min(maxlist) < a[i]):
            maxlist.remove(min(maxlist))
            maxlist.append(a[i])
            #print(maxlist)

    print(sum(maxlist))


n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
print(sum(sorted(l, reverse=True)[:k]))


t = raw_input().split()
a = int(t[0])
b = int(t[1])
l = map(int, raw_input().strip().split())
l.sort()
l = l[::-1]
ans = 0
for x in range(b):
	ans += l[x]
print(ans)


# coding: utf-8

n = input()
print "ABC" + str(n)


# -*- coding:utf-8 -*-
N = int(input())
print("ABC"+str(N))


num = int(input())
print ("ABC{}".format(num))


#!usr/bim/python
#! -*- coding: utf-8 -*-

num = raw_input()

print "ABC"+num


# -*- coding: utf-8 -*-
n = int(raw_input())
if n >= 100 and n <= 999:
    print "ABC" + str(n)
else:
    exit


N = int(input())
print("ABC{0:03d}".format(N))


x = int(input())
print('ABC', x, sep='')


a = int(input())
b = "ABC" + str(a)

print(b)


#!/usr/bin/python

import sys

def main(argv):
    for line in sys.stdin:
        print("ABC{0}".format(int(line)))

if __name__ == "__main__":
    main(sys.argv)


nb = int(input())
print("ABC",end = "")
print(nb)


from sys import stdin
print 'ABC'+stdin.readline()


def main():
    print("ABC" + input())

if __name__ == '__main__':
    main()


# coding: utf-8
# Here your code !
N = input()
print("ABC" + N)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)

def main():
    N = int(input())
    print("ABC{:03d}".format(N))

if __name__ == "__main__": main()


N = int(raw_input())
print "ABC{}".format(N)


N = raw_input()
print('ABC{0}'.format(N))


import sys

def main():
    args = sys.stdin.readline().split()
    N = int(args[0])

    print('ABC' + str(N))

main()


n = input()
print('ABC' + str(n).zfill(3))


# a = list(map(int, input().split()))
# print(a)

n = int(input())

print("ABC" + str(n))


#! /usr/bin/env python3

print('ABC' + input())


import sys

# sys.stdin = open('a1.in')

def read_int_list():
    return list(map(int, input().split()))

def read_str_list():
    return input().split()

def read_int():
    return int(input())

def read_str():
    return input()

n = read_int()
print('ABC' + str(n))


def a():
    n = int(input())
    print('ABC'+str(n))

a()


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

import math

n = input()
print("ABC" + n)


n = int(input())
print("ABC",n,sep = '')


def main():
    print("ABC{}".format(input()))

if __name__ == "__main__":
    main()


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

count = input()

print("ABC" + str(count))


s = input()
s = int(s)
print("ABC{0}".format(s))


#!/usr/bin/env python

num = input()

print("ABC" + num)


number = input()
Tournament = "ABC"
Tournament += number
print(Tournament)


def main():
	n = input()
	print("ABC" + n)

if __name__ == '__main__':
	main()


N = int(raw_input())
data = [1, 2, 4, 8, 16, 32, 64]
print max([d for d in data if d <= N])


import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**9
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    N = I()
    r = 0
    while N>=2:
        N //= 2
        r += 1

    return 2**r

print(main())


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

N = int(raw_input())

if N >= 64:
    print '64'
elif N >= 32:
    print '32'
elif N >= 16:
    print '16'
elif N >= 8:
    print '8'
elif N >= 4:
    print '4'
elif N >= 2:
    print '2'
else:
    print '1'


Nmax = int(input())
ans = 1
maxnum = 0
for N in range(1, Nmax+1):
    cnt=0
    N_before = N
    while 1:
        if int(N/2) == int((N+1)/2):
            N = N/2
            cnt +=1
        else:
            break
    if cnt > maxnum:
        maxnum = cnt
        ans = N_before
print (ans)


n = int(input())
for i in range(7):
    if 2 ** i <= n < 2 ** (i+1):
        print(2 ** i)
        break


#!/usr/bin
# -*- coding="utf-8" -*-

n = int(input())
if n >= 64:
  a = 64
elif n >= 32:
  a = 32
elif n >= 16:
  a = 16
elif n >= 8:
  a= 8
elif n >= 4:
  a = 4
elif n >= 2:
  a = 2
else:
  a = 1
print(a)


n = int(input())
i=1
while ( i * 2 <= n):
    i *= 2
print(i)


N = int(input())

tmp = 1
while(1):
    if tmp*2 > N:
        break
    else:
        tmp *= 2

print(tmp)


def countdiv(n):
	m = n
	cnt = 0
	while m % 2 == 0:
		cnt += 1
		m = m / 2
	return cnt

n = int(raw_input())
max = 0
nmb = 1

for i in range(1, n+1):
	tmp = countdiv(i)
	if tmp > max:
		max = tmp
		nmb = i

print nmb


x = input()
x = int(x)
y = 1
while x>=y:
    y = y*2
else:
    print(int(y/2))


n = int(input())
ans = 1
while n >= ans*2:
    ans *= 2
print(ans)


N = int(raw_input())

S = range(N)
for i in S:
    S[i] = i + 1

res = []

for i in S:
    num = i
    count = 0

    while i%2 == 0:

        i = i/2
        count += 1

    res.append((count,num))

res.sort()

Anser = res[-1][1]

print Anser


N = int(input())

li = [2**i for i in range(7)]

for i, x in enumerate(li, 1):
    if N >= li[len(li)-i]:
        print(li[len(li)-i])
        break
    else:
        continue


n = int(input())
for i in range(8):
    if 2 ** i <= n < 2 ** (i+1):
        print(2 ** i)
        break


n = int(input())

if n >= 64:
    print(64)
elif n >= 32:
    print(32)
elif n >= 16:
    print(16)
elif n >= 8:
    print(8)
elif n >= 4:
    print(4)
elif n >= 2:
    print(2)
else:
    print(1)


N = int(input())
s = 7
i = 0

for i in range(s):
    t = 64 >> i
    if (0 != (N & int(t))):
        print(t)
        break


n = map(int, raw_input().split())[0]

i = 1

while i * 2 <= n:
    i *= 2

print i


n=int(input())
a=[2**x for x in range(7)]
a=a[::-1]
for x in a:
    if n>=x:
        ans=x
        break
print(ans)


n = int(input())
bi = [2 ** i for i in range(8)]
for i in range(8):
    if n < bi[i]:
        print(bi[i - 1])
        break


n = int(input())

import math as m
print(2** m.floor(m.log(n, 2)))


n=int(input())
a=1
while a*2<=n:
 a*=2
print(a)


N = int(input())
if N < 2:
    print('1')
elif N < 4:
    print('2')
elif N < 8:
    print('4')
elif N < 16:
    print('8')
elif N < 32:
    print('16')
elif N < 64:
    print('32')
else:
    print('64')


n=int(input())
l = [2,4,8,16,32,64]
if n==1:
    print(1)
else:
    while True:
        a=l.pop()
        if n>=a:
            print(a)
            break


n = int(input())

breakNum = 1

while breakNum*2 <= n:
	breakNum *= 2

print(breakNum)


N = int(input())
i = 1
while i <= N:
    i *= 2
print(i//2)


n = int(input())
num = 1
while True:
    if num*2 > n:
        print(num)
        break
    elif num*2 == n:
        print(num*2)
        break
    else:
        num *= 2


N = int(input())

for i in range(10):
    if 2 ** i <= N < 2 ** (i+1):
        print(2**i)
        break


#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

n = int(sys.stdin.readline())

x = 2
while x <= n:
	x *= 2

if n < 2:
	print (str(n))
else:
	print (str(int(x/2)))


# coding: utf-8
# Here your code !
n = int(input())
i = 1
while i <8:
    if n < 2**i:
        print (2**(i-1))
        break
    else:
        i += 1


n = int(input())
a = [1,2,4,8,16,32,64]
b = 0
for x in a:
 if n < x:
  break
 b = x
print(b)


N = int(input())

if N == 1:
	print(1)
elif N < 4:
	print(2)
elif N < 8:
	print(4)
elif N < 16:
	print(8)
elif N < 32:
	print(16)
elif N < 64:
	print(32)
else:
	print(64)


# coding: utf-8

n = int(input())
for i in range(7, -1, -1):
    a = 2**i
    if n >= a:
        print(a)
        exit()


# coding: utf-8

if __name__ == "__main__":
    n = int(input())
    r = 0
    while 2**r <= n:
        r += 1

    r -= 1

    print(2**r)


N = int(input())
cnt_max = 0
ans = 1
for n in range(1 , N+1):
    cnt = 0
    z = n
    while True:
        if z%2 == 0:
            cnt += 1
            z = z / 2
        else:
            break
    if cnt > cnt_max:
        cnt_max = cnt
        ans = n

print(ans)


import math
import numpy as np
print(int(2**math.floor(np.log2(int(raw_input())))))


#!usr/bim/python
#! -*- coding: utf-8 -*-

num = raw_input()
num = int(num)

i = 0
while 1:
    if 2**i <= num:
        i += 1
    else:
        break

ans = 2**(i - 1)

print ans


num = int(input())
cnt =0
while num>1:
    num = int(num/2)
    cnt +=1
print(2**cnt)


N = int(input())
secound = [64,32,16,8,4,2,1]
for i in secound:
    if N >= i:
        print(i)
        break


input_number = int(input())
count = 0
buff_rank = []

for i in range(1,input_number+1):
    num = i
    while num % 2 == 0:
        num = num // 2
        count = count + 1
    buff_rank.append(count)
    count = 0

print(buff_rank.index(max(buff_rank))+1)


n = int(raw_input())
a = 1
while a*2 <= n:
    a *= 2
print a


N = int(input())

i = 1
while(1):
    if i*2 > N:
        break
    i = i*2
print(i)


a = int(input())
cnt = 0
while a:
    cnt += 1
    a >>= 1
print(1 << (cnt - 1))


from math import log
print (max(1, 2**int(log(int(input()), 2))))


n=int(input())

ans=1
while True:
    if n>ans: ans*=2
    elif n==ans: break
    else: ans/=2; break

print(int(ans))


N = int(input())

c_max = 0
i_max = 1
for i in range(1, N+1):
    c = 0
    num = i
    while True:
        if num % 2 != 0:
            break
        num = num // 2
        c += 1
    if c > c_max:
        c_max = c
        i_max = i

print(i_max)


arr=[64,32,16,8,4,2,1]
n=int(input())
for i in arr:
    if n>=i:
        print(i)
        break


n = int(input())
nums = [2**x for x in range(10)]
while True:
	if n in nums:
		print(n)
		break
	else:
		n -= 1


N = input()

i = 1

while i <= N:
    i *= 2

print i / 2


N = int(input())
ans = 64
while ans >= 1:
    if N >= ans: break
    ans //= 2
print(ans)


import math
n=int(input())

if n==1:
    print(1)
else:
    m=math.log2(n)
    ans=math.pow(2,math.floor(m))
    print(int(ans))


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

import math

def check(n, i):
    if (2 ** i > n):
        return 2 ** (i-1)
    else:
        return check(n, i+1)

n = int(input())
print(check(n, 0))


a = 100
l = [0]*a
t = 1
for x in xrange(a):
	while t%2 == 0:
		t = t/2
		l[x] += 1
	t = x+2
a = int(raw_input())
ma = 0
mi = 1
for x in range(a):
	if l[x] > ma:
		ma = l[x]
		mi = x
if a == 1:
	print(1)
else:
	print(mi+1)


N=int(input())
ans=0
while 2**ans <= N:
    ans += 1

print(2**(ans-1))


N = int(input())

if N == 1:
    print(N)
else:
    for i in range(N):
        if 2**i > N:
            print(2**(i-1))
            break


n = int(input())
i = 1
while i <= n:
    i *= 2
print(int(i/2))


N = int(input())
i = 0
while 2**i <= N:
    i = i + 1
print(2**(i-1))


import sys

# sys.stdin = open('b1.in')

def read_int_list():
    return list(map(int, input().split()))

def read_str_list():
    return input().split()

def read_int():
    return int(input())

def read_str():
    return input()

n = read_int()
res = 0
for i in range(100):
    r = 2 ** i
    if r <= n:
        res = r
    else:
        break
print(res)


N=int(raw_input())

i=1
while 2**i <= N:
    i+=1

print 2**(i-1)


from math import log2
from math import floor
N=int(input())
print(2**floor(log2(N)))


n = int(input())
pow2 = [2 ** item for item in range(10)]
for item in pow2[::-1]:
    if(item <= n):
        print(item)
        break


N=int(input())
x=[]
for i in range(200):
    x.append(0)
for i in range(200):
    ori=i
    while ori!=0:
        if ori%2==0:
            ori=ori/2
            x[i]+=1
        else:
            break
maxi=1
maxv=0
for i in range(200):
    if maxv<x[i] and i<N+1:
        maxv=x[i]
        maxi=i
print(maxi)


m = int(input())
a = 1
for c in range(7):
  if (2 ** c) > m:
    break
  a = (2 ** c)

print(a)


n = int(input())
if n == 1:
    print(1)
    exit()

ans = [0] * 2
for i in range(1, n + 1):
    num = i
    cnt = 0
    while num % 2 == 0:
        num //= 2
        cnt += 1

    if cnt > ans[1]:
        ans[0] = i
        ans[1] = cnt

print(ans[0])


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

N = int(input())

cnt = 0
while True:
    if N >= 2:
        N = N // 2
        cnt += 1
    else:
        break

print(2**cnt)


# coding: utf-8

n = input()
m = 0
rank = 1
for i in range(1, n+1):
    j = i
    c = 0
    while True:
        if j % 2 == 0:
            j /= 2
            c += 1

        else:
            if m < c:
                m = c
                rank = i
            break

print rank


import math
N=int(input())
L=int(math.log(N,2))
print(2**L)


N = int(input())
p = 0
while True:
    if N < 2**p:
        print(2**(p-1))
        break
    else:
        p=p+1


N = int(input())
A = 1
while A <= N:
    A *= 2
A /= 2
print(int(A))


import sys
import math

def main():
    args = sys.stdin.readline().split()
    N = int(args[0])

    X = 0
    while True:
        X += 1
        temp = math.pow(2, X)
        if temp > N:
            temp = math.pow(2, X-1)
            break

    print(int(temp))

main()


N = int(raw_input())
n = 1
while n * 2 <= N:
  n *= 2
print n


from sys import stdin
ma = -1
ans = -1
n = int(stdin.readline())
for i in xrange(1,n+1):
 x = i
 cn = 0
 while x%2==0:
  x/=2;cn+=1
 if cn > ma:
  ma = cn;ans = i
print ans


N = int(input())
ans = 1
if (N >= 64):
    ans = 64
elif (N >= 32):
    ans = 32
elif (N >= 16):
    ans = 16
elif (N >= 8):
    ans = 8
elif (N >= 4):
    ans = 4
elif (N >= 2):
    ans = 2
print(ans)


def b():
    n = int(input())
    two_l = [ 2**x for x in range(7) ]
    res = 1
    for i in two_l:
        if i <= n:
            res = i
        else:
            break
    print(res)

b()


n = int(input())

x = 1
while(x*2 <= n):
    x *= 2

print(x)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)

def main():
    N = int(input())

    k = math.floor(math.log(N, 2))
    print(2**k)

if __name__ == "__main__": main()


N = int(input())
ans = 1
for i in range(N):
    t = 2 * ans
    if t > N:
        print(ans)
        break
    ans = t


#coding: utf-8
N = int(input())

base = 2
mul = 0
while True:
    mul += 1
    if base ** mul > N:
        break

print(base ** (mul - 1))


N = int(input())

k = [2 ** i for i in range(1, 8)]

M = 1

for i in k:
    if i <= N:
        M = i

print(M)


# cook your dish here
from math import *
n=int(input())
print(2**floor(log2(n) ))


import logging
logging.basicConfig(level=logging.CRITICAL,format=' %(asctime)s - %(levelname)s - %(message)s')

def power(n):
    i = 1
    logging.info('func start')
    while n > 0:
        i *= 2
        n -= 1
        logging.debug('i = {}, n = {}'.format(i,n))
    logging.info('func end')
    return i

i = 0
n = int(input())
logging.info('in loop')
while not (power(i + 1) > n):
    i = i + 1
    logging.debug('i = {}, pow(i) = {}'.format(i,power(i)))

logging.info('out loop')
print(power(i ))


n=int(input())
t=[2,4,8,16,32,64]
c=0
if n==0:print("0")
elif n==1:print("1")
elif n>=64:print("64")
else:
    for i in t:
        if n < i:
            print(t[c-1])
            break
        c=c+1


# coding: utf-8

N = int(input())

ma = -1
res = 1
for i in range(1, N+1):
    num = i
    tmp = num
    count = 0
    while num % 2 == 0:
        count += 1
        num = num / 2

    if count > ma:
        res = tmp
        ma = count

print(res)


N = int(input())
if N >= 64:
    print(64)
elif N >= 32:
    print(32)
elif N >= 16:
    print(16)
elif N >= 8:
    print(8)
elif N >= 4:
    print(4)
elif N >= 2:
    print(2)
else:
    print(1)


def main(N):
    n_div_max = 0
    answer = 1
    for n in range(1, N + 1):
        _n = n
        tmp_n_div = 0
        while True:
            _n, m = divmod(_n, 2)
            if m > 0:
                break
            tmp_n_div += 1

        if tmp_n_div >= n_div_max:
            n_div_max = tmp_n_div
            answer = max(answer, n)

    print(answer)

def main2(N):
    # 128 = 2 ** 7
    for i in reversed(range(7)):
        n = 2 ** i
        if N >= n:
            print(n)
            return

if __name__ == '__main__':
    N = int(input())
    main2(N)


N=int(input())
for i in range(8):
    if 2**i <= N < 2**(i+1):
        print(2**i)
        break


N = int(input())

res_list = []
tmp = 1
while True:
    if tmp > N:
        break
    res_list.append(tmp)
    tmp *= 2

print(max(res_list))


import math
t=int(input())
x=0
i=0
while x<=t:
  x=math.pow(2,i)
  i+=1
print(int(pow(2,i-2)))


N = int(input())

index = -1
for i in range(7):
    if 2 ** i <= N:
        index += 1
    else:
        pass

print(2 ** index)


N = int(raw_input())
ans = 64
while ans > N: ans /= 2
print ans


N=int(input())
x = 1
while x <=N:
	if x*2 >N:
		print(x)
		break
	x = x*2


def main():
    N = int(input())

    if N == 1:
        print(1)
        return

    x = (64, 32, 16, 8, 4, 2)
    for i in x:
        if i <= N:
            print(i)
            break

main()


# -*- coding:utf-8 -*-
N = int(input())
a = [tmp for tmp in reversed(range(1,N+1)) if tmp%2 == 0]
ans = 0
for tmp in range(7):
    if N == 1:
        ans = 1
        break
    b = [tmp2//2 for tmp2 in a if tmp2%2 == 0]
    if len(b) != 0:
        ans += 1
    else:
        ans = (2**ans)*a.pop()
        break
    a = [tmp2 for tmp2 in b]
print(ans)


N = int(input())

ans = 64
while N < ans:
    ans //= 2

print(ans)


# coding: utf-8
# Here your code !
n=input()
N=int(n)
a=0
ans=[]
for i in range(N):
    I=i+1
    a=0
    if I%2==0:
        a=a+1
        P=I/2
        for w in range(100):
            if P%2==0:
                a=a+1
                P=P/2
            else:
                ans.append(a)
                break
    else:
        ans.append(0)
max_idx = ans.index(max(ans))
print(max_idx+1)


maxNum = int(input())
favNum = 1
max2 = 0

for i in range(1,maxNum+1):
    currNum = i
    j = 0
    while(1):
        if currNum % 2 == 1:
            break
        else:
            currNum = currNum/2
            j += 1
    if max2 < j:
        max2 = j
        favNum = i

print(favNum)


N = int(input())

maxcount = -1
maxi = 0
for i in range(1, N+1):
  count = 0
  cur_i = i
  while True:
    if i % 2 == 0:
      i = i // 2
      count += 1
    else:
      break
  if count > maxcount:
    maxcount = count
    maxi = cur_i
print(maxi)


a=int(input())
b=int(2)
c=int
if 1==a:
    print(a)
else:
    while b<100:
        c=b
        b=b*2

        if(a<b)and(a>=c):
            print (c)


n = int(input())
count = 0
for i in range(1, n):
    if n >= pow(2, i):
        count = count + 1
    else:
        break
print(pow(2,count))


a = int(input())
i = 1
while(i<=a):
	i *= 2
print(int(i/2))


n = int(input())
two = 1
while True:
    if two * 2 > n:
        break
    two *= 2
print(two)


N = int(input())

if N == 1:
    print("1")
else:
    l = [2**x for x in list(range(1, 8))]
    a = [ x for x in l if x <= N]
    print(max(a))


from math import floor, log2
n = int(input())
print(2 ** floor(log2(n)))


# encoding:utf-8

def main():
	n = int(input())
	powers = [2 ** i for i in range(7)]
	out = max([x for x in powers if x <= n])
	print(out)

if __name__ == '__main__':
	main()


N=int(input())

C=0
L=[]

if N==1:
    print(1)

else:
    for i in range(8):
        C=2**i
        L.append(C)
        if C>N:
            print(L[-2])
            break


N = int(input())

result = 0
while N / 2 >= 1.0:
    N /= 2
    result += 1
print(2**result)


n = int(input())
ret = 1
while 2*ret <= n:
  ret *= 2
print(ret)


inp = int(input())
count = 0
serch = 1

for i in range(1,inp + 1):
	a = i
	j = 1
	while j <= i:
		if a % 2 != 0:
			if j - 1 > count:
				count = j - 1
				serch = i
			break
		a = a / 2
		j += 1

print(serch)


from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10

def count(n):
    ans = 0
    while n % 2 == 0:
        n //= 2
        ans += 1
    return ans

def main():
    N = int(input())
    ans, num = 0, 0
    for i in range(1, N + 1):
        if count(i) >= num:
            num = count(i)
            ans = i

    print(ans)

if __name__ == '__main__':
    main()


n = int(input())
i=1
t=1
while(i <= n):
    t = i
    i *= 2
print(t)


import math as m
s=int(input())
print(2**int(m.log2(s)))


N = int(input())

for i in range(10):
    if N > 2**i:
        continue
    elif N < 2**i:
        break

print(2**(i-1))


N = int(input())

sig = [2,4,8,16,32,64,128]
sig.reverse()

if N == 1:
    print('1')
    exit()

for i in sig:
    if i <= N:
        print(i)
        exit()


a=int(input())
b=1
while (b<<1)<=a:
    b=b<<1
print(b)


n = int(input())
if n < 2:
    print(1)
elif n < 4:
    print(2)
elif n < 8:
    print(4)
elif n < 16:
    print(8)
elif n < 32:
    print(16)
elif n < 64:
    print(32)
else:
    print(64)


a = int(input())
for i in range(a):
  if 2 ** i > a:
    break
  elif 2 ** i <= a:
    count = 2 ** i

print(count)


N = int(input())
l = [2**n for n in range(10) if 2**n <= N]
print(max(l))


#!/usr/bin/python

import math
import sys

def main(argv):
    for line in sys.stdin:
        N = int(line)
        index = int(math.log(N, 2))
        print(int(math.pow(2, index)))

if __name__ == "__main__":
    main(sys.argv)


import sys

N = int(input())						# 5

i = 1
while (i*2) <= N:
	i *= 2

print(i)


N = int(input())
ans = 1
while ans * 2 <= N:
    ans *= 2
print(ans)


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

num = int(input())

if num >= 64:
    print(str(64))
elif num >= 32:
    print(str(32))
elif num >= 16:
    print(str(16))
elif num >= 8:
    print(str(8))
elif num >= 4:
    print(str(4))
elif num >= 2:
    print(str(2))
else:
    print(str(1))


n = int(input().strip())
while True:
 if n & (n-1) == 0:
  print(n)
  break
 n -= 1


N = int(input())
ans = 0
for i in range(7):
	if N >= 2 ** i:
		ans = 2 ** i
	else:
		break
print(ans)


a, b = map(int, raw_input().strip().split())
print (a - 1) * (b - 1)


n, m = map(int, input().split())
print((n - 1) * (m - 1))


def main():
    N, M = map(int, input().split())

    ans = (N - 1) * (M - 1)
    print(ans)

main()


n, m = map(int,input().split(" "))

result = (n-1) * (m-1)

print(result)


def a():
    n, m = map(int, input().split())
    print((n-1) * (m-1))

a()


# encoding:utf-8

def main():
	n, m = list(map(int, input().split()))
	print((n - 1) * (m - 1))

if __name__ == '__main__':
	main()


n,m = input().split()
n = int(n)
m = int(m)

print((n-1)*(m-1))


def main():
    n, m = (int(x) for x in input().split())
    n += 1
    m += 1

    print(n * m - 2 * (n + m) + 4)

if __name__ == "__main__":
    main()


'''input
3 4
'''
n , m = map(int ,raw_input().split())
print (n-1)*(m-1)


#!/usr/bin/python

n, m = map(int, input().split(" "))

ans = (n-1) * (m-1)
print(ans)


n,m = list(map(int,input().split()))
print((n-1)*(m-1))


a,b = map(int,input().split())
print((a-1) * (b-1))


n, m = input().split()
n = int(n)
m = int(m)
output = (n-1)*(m-1)

print(output)


n, m = map(int, input().split())
print((n-1)*(m-1))


a,b=list(map(int, input().split()))
print ((a-1)*(b-1))


#!/usr/bin/env python
# -*- coding: utf-8 -*-

n, m = map(int, raw_input().split())
area = (n-1) * (m-1)
print area


n , m = map(int , input().split())
print((n-1) * (m-1))


n,m = list(map(int, input().split()))

print ((n-1)*(m-1))


n,m = map(int,raw_input().split())
print((n-1)*(m-1))


a, b = map(int, input().split())
print((a - 1) * (b - 1))


# import numpy as np
n, m = map(int, input().split())

print((n-1) * (m-1))


n,m = map(int, raw_input().split())
print (n-1)*(m-1)


import sys

# sys.stdin = open('a1.in')

def read_int_list():
    return list(map(int, input().split()))

def read_str_list():
    return input().split()

def read_int():
    return int(input())

def read_str():
    return input()

def main():
    n, m = read_int_list()
    res = (n - 1) * (m - 1)
    print(res)

main()


n, m = map(int, raw_input().split())
print (n - 1)*(m - 1)


temp = input()
n, m = temp.split()
city = (int(n)-1)*(int(m)-1)
print(city)


n,m = map(int, raw_input().split())
print((n-1)*(m-1))


n,m = map(int, input().split())
print((n-1)*(m-1))


def main():
    n, m = [int(i) for i in input().split()]
    #print(n, m)
    print((n-1) * (m-1))

if __name__=="__main__":
    main()


n,m = map(int,input().split())

A=(n-1)*(m-1)
print(A)


# -*- coding: utf-8 -*-
"""
http://abc069.contest.atcoder.jp/tasks/abc069_a
"""

def main():
    n, m = map(int, input().split())
    print((n-1)*(m-1))

if __name__ == '__main__':
    main()


# coding: utf-8
# Here your code !
a=input()
b=a.split()
n=int(b[0])
m=int(b[1])

print((n-1)*(m-1))


n, m = map(int, input().split(" "))

print((n-1)*(m-1))


n, m = list(map(int, input().split()))
print((n-1) *(m-1))


n, m = list(map(int, input().split()))
print((n-1)*(m-1))


n,m = map(lambda i:int(i)-1,input().split(' '))
print(n*m)


n, m = map(int, input().split())
print((m - 1) * (n - 1))


n, m = map(int, input().split())
block = (n - 1) * (m - 1)
print(block)


n, m = map(int, raw_input().split())
print (n-1) * (m-1)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)

def main():
    N, M = map(int, input().split())

    print((N-1)*(M-1))

if __name__ == "__main__": main()


n, m = map(int, raw_input().split())
print (n - 1) * (m - 1)


A, B=list(map(int, input().split()))
print((A-1)*(B-1))


a = input().split()
b = int(a[0])
c = int(a[1])
b = b-1
c = c-1
print(b*c)


(n, m) = tuple(map(int, input().split(" ")))
print((n-1) * (m-1))


n, m = map(int, input().split())

print((n-1)*(m-1))


n,m=map(int,input().split())

ans=(n-1)*(m-1)

print(ans)


def main():
    n, m = map(int, input().split())
    print((n - 1) * (m - 1))

if __name__ == '__main__':
    main()


# your code goes here
n,m = map(int,input().split())
print ((n-1)*(m-1))


n, m = map(int,input().split())

print((n-1)*(m-1))


n, m = map(int, input().split())
print((n - 1) * (m - 1))


n, m = map(int, input().split())

h = n - 1
w = m - 1
ans = h * w
print(ans)


n, m = map(int, input().split())
print((n-1) * (m-1))


x,y = map(int,raw_input().split())
print (x-1)*(y-1)


n, m = map(int,raw_input().split(' '))
print (n-1)*(m-1)


n, m = [int(e) for e in input().split()]
print((n - 1) * (m - 1))


n,m = map(int,input().split())
print((n-1) * (m-1))


n, m=map(int, input().split())
print( (n-1)*(m-1))


def Solution(a,b):
    return (a-1)*(b-1)

if __name__=="__main__":
    input = raw_input().split(" ")
    print Solution((int)(input[0]), (int)(input[1]))


# coding: utf-8

n, m = map(int, raw_input().split())
print ((n+1)*(m+1))-(n*2+m*2)


n ,m = [int(i) for i in input().split()]
print((n - 1) * (m - 1))


x, y = list(map(int, input().split()))

print((x - 1) * (y - 1))


# -*- coding: utf-8 -*-
input_cl = input().split()
input_cl = [int(i) for i in input_cl]
n = input_cl[0]
m = input_cl[1]
sector = (n-1) * (m-1)
print(sector)


m, n = (int(i) for i in input().split())
print((m-1)*(n-1))


s = raw_input()
s = s.split(' ')
s = [int(x) for x in s]
n, m = s

print((n-1)*(m-1))


l = map(int, input().split())
l = list(l)
print(str((l[0]-1)*(l[1]-1)))


n, m = map(int, input().split())
print( (n-1)*(m-1) )


m,n = map(int, input().split())
print((m-1)*(n-1))


#!usr/bim/python
#! -*- coding: utf-8 -*-

nm = raw_input()
nm = nm.split()
nm = map(int, nm)

if nm[0] < 2 or nm[1] < 2:
    ans = 0
else:
    ans = (nm[0]-1)*(nm[1]-1)

print ans


N,M=(int(i) for i in input(). split ())
N-=1
M-=1
print (N*M)


astr = input().split()
anum = []
for i in astr:
    anum.append(int(i))
print((anum[0]-1)*(anum[1]-1))


input_line = map(int,raw_input().split(" "))
n = input_line[0]
m = input_line[1]

print (n-1) * (m-1)