import argparse
import os







class 			SCREAMING_SNAKE_CASE__ :
       A				:     Union[str, Any]					    =     "block_{0}.dat"

       def __init__(				self :			Dict       ,       _lowerCAmelCase :			int       ):
           __snake_case    :							Optional[int]             =  filename
           __snake_case    :							Union[str, Any]             =  []

       def        snake_case__  (				self :			Optional[int]       ,       _lowerCAmelCase :			Optional[int]       ,       _lowerCAmelCase :			List[Any]       ):
           __snake_case    :							Tuple             =  self.BLOCK_FILENAME_FORMAT.format(_snake_case       )
           with open(_snake_case       ,       """w"""       ) as file:
               file.write(_snake_case       )
           self.block_filenames.append(_snake_case       )

       def        snake_case__  (				self :			str       ):
           return self.block_filenames

       def        snake_case__  (				self :			Any       ,       _lowerCAmelCase :			Tuple       ,       _lowerCAmelCase :			Dict=None       ):
           __snake_case    :							Optional[Any]             =  0
           with open(self.filename       ) as file:
               while True:
                   __snake_case    :							Optional[int]             =  file.readlines(_snake_case       )

                   if lines == []:
                       break

                   if sort_key is None:
                       lines.sort()
                   else:
                       lines.sort(key=_snake_case       )

                   self.write_block("""""".join(_snake_case       )       ,       _snake_case       )
                   i += 1





       def        snake_case__  (				self :			Optional[Any]       ):
           map(os.remove       ,       self.block_filenames       )







class 			SCREAMING_SNAKE_CASE__ :

       def        snake_case__  (				self :			Dict       ,       _lowerCAmelCase :			Optional[int]       ):
           __snake_case    :							Any             =  -1
           __snake_case    :							List[str]             =  None

           for i in range(len(_snake_case       )       ):
               if min_str is None or choices[i] < min_str:
                   __snake_case    :							str             =  i

           return min_index







class 			SCREAMING_SNAKE_CASE__ :

       def __init__(				self :			Optional[int]       ,       _lowerCAmelCase :			Tuple       ):
           __snake_case    :							Union[str, Any]             =  files
           __snake_case    :							Union[str, Any]             =  set()
           __snake_case    :							int             =  len(_snake_case       )
           __snake_case    :							List[Any]             =  {i: None for i in range(self.num_buffers       )}

       def        snake_case__  (				self :			Dict       ):
           return {
               i: self.buffers[i] for i in range(self.num_buffers       ) if i not in self.empty
           }

       def        snake_case__  (				self :			Tuple       ):
           for i in range(self.num_buffers       ):
               if self.buffers[i] is None and i not in self.empty:
                   __snake_case    :							Dict             =  self.files[i].readline()

                   if self.buffers[i] == "":
                       self.empty.add(_snake_case       )
                       self.files[i].close()

           if len(self.empty       ) == self.num_buffers:
               return False

           return True





       def        snake_case__  (				self :			List[str]       ,       _lowerCAmelCase :			Optional[Any]       ):
           __snake_case    :							Optional[int]             =  self.buffers[index]
           __snake_case    :							List[str]             =  None

           return value







class 			SCREAMING_SNAKE_CASE__ :

       def __init__(				self :			List[str]       ,       _lowerCAmelCase :			Tuple       ):
           __snake_case    :							Dict             =  merge_strategy

       def        snake_case__  (				self :			str       ,       _lowerCAmelCase :			Any       ,       _lowerCAmelCase :			Optional[int]       ,       _lowerCAmelCase :			Dict       ):
           __snake_case    :							List[str]             =  FilesArray(self.get_file_handles(_snake_case       ,       _snake_case       )       )
           with open(_snake_case       ,       """w"""       ,       _snake_case       ) as outfile:
               while buffers.refresh():
                   __snake_case    :							Optional[int]             =  self.merge_strategy.select(buffers.get_dict()       )
                   outfile.write(buffers.unshift(_snake_case       )       )





       def        snake_case__  (				self :			Dict       ,       _lowerCAmelCase :			List[str]       ,       _lowerCAmelCase :			Dict       ):
           __snake_case    :							Optional[Any]             =  {}

           for i in range(len(_snake_case       )       ):
               __snake_case    :							Optional[Any]             =  open(filenames[i]       ,       """r"""       ,       _snake_case       )  # noqa: UP015

           return files







class 			SCREAMING_SNAKE_CASE__ :

       def __init__(				self :			str       ,       _lowerCAmelCase :			int       ):
           __snake_case    :							Optional[int]             =  block_size

       def        snake_case__  (				self :			Any       ,       _lowerCAmelCase :			Optional[int]       ,       _lowerCAmelCase :			Any=None       ):
           __snake_case    :							int             =  self.get_number_blocks(_snake_case       ,       self.block_size       )
           __snake_case    :							Dict             =  FileSplitter(_snake_case       )
           splitter.split(self.block_size       ,       _snake_case       )

           __snake_case    :							Dict             =  FileMerger(NWayMerge()       )
           __snake_case    :							Optional[int]             =  self.block_size / (num_blocks + 1)
           merger.merge(splitter.get_block_filenames()       ,       filename + """.out"""       ,       _snake_case       )

           splitter.cleanup()





       def        snake_case__  (				self :			Tuple       ,       _lowerCAmelCase :			Optional[Any]       ,       _lowerCAmelCase :			Union[str, Any]       ):
           return (os.stat(_snake_case       ).st_size / block_size) + 1







def  __lowerCAmelCase							(						__SCREAMING_SNAKE_CASE    : str					):







    '''simple docstring'''





    if string[-1].lower() == "k":
        return int(string[:-1]					) * 1_0_2_4
    elif string[-1].lower() == "m":
        return int(string[:-1]					) * 1_0_2_4 * 1_0_2_4
    elif string[-1].lower() == "g":
        return int(string[:-1]					) * 1_0_2_4 * 1_0_2_4 * 1_0_2_4
    else:
        return int(_SCREAMING_SNAKE_CASE					)







def  __lowerCAmelCase							(						):







    '''simple docstring'''
    __snake_case    :							Union[str, Any]             =  argparse.ArgumentParser()
    parser.add_argument(
        """-m"""						,				"""--mem"""						,				help="""amount of memory to use for sorting"""						,				default="""100M"""					)
    parser.add_argument(
        """filename"""						,				metavar="""<filename>"""						,				nargs=1						,				help="""name of file to sort"""					)
    __snake_case    :							List[str]             =  parser.parse_args()

    __snake_case    :							str             =  ExternalSort(parse_memory(args.mem					)					)
    sorter.sort(args.filename[0]					)


if __name__ == "__main__":
     main()






'''simple docstring'''
import math
from itertools import permutations


def       a__    (  _SCREAMING_SNAKE_CASE					:    int							)			-> bool:


	"""simple docstring"""





	if 1 < number < 4:
		# 2 and 3 are primes
		return True
	elif number < 2 or number % 2 == 0 or number % 3 == 0:
		# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
		return False

	# All primes number are in format of 6k +/- 1
	for i in range(5     ,							int(math.sqrt(_SCREAMING_SNAKE_CASE							) + 1							)     ,							6							):
		if number % i == 0 or number % (i + 2) == 0:
			return False
	return True


def       a__    (  _SCREAMING_SNAKE_CASE					:    int     ,							_SCREAMING_SNAKE_CASE					:    list							)			-> bool:


	"""simple docstring"""





	UpperCAmelCase_ , UpperCAmelCase_			:	Any      =   0, len(_SCREAMING_SNAKE_CASE							) - 1
	while left <= right:
		UpperCAmelCase_			:	List[str]      =   (left + right) // 2
		if prime_list[middle] == target:
			return True
		elif prime_list[middle] < target:
			UpperCAmelCase_			:	Dict      =   middle + 1
		else:
			UpperCAmelCase_			:	int      =   middle - 1

	return False


def       a__    (  )			-> Tuple:


	"""simple docstring"""





	UpperCAmelCase_			:	Dict      =   [n for n in range(10_01     ,							1_00_00     ,							2							) if is_prime(_SCREAMING_SNAKE_CASE							)]
	UpperCAmelCase_			:	Optional[int]      =   []

	for number in prime_list:
		UpperCAmelCase_			:	Optional[Any]      =   []

		for prime_member in permutations(list(str(_SCREAMING_SNAKE_CASE							)							)							):
			UpperCAmelCase_			:	List[Any]      =   int("".join(_SCREAMING_SNAKE_CASE							)							)

			if prime % 2 == 0:
				continue

			if search(_SCREAMING_SNAKE_CASE     ,							_SCREAMING_SNAKE_CASE							):
				tmp_numbers.append(_SCREAMING_SNAKE_CASE							)

		tmp_numbers.sort()
		if len(_SCREAMING_SNAKE_CASE							) >= 3:
			candidates.append(_SCREAMING_SNAKE_CASE							)

	UpperCAmelCase_			:	Tuple      =   []
	for candidate in candidates:
		UpperCAmelCase_			:	Union[str, Any]      =   len(_SCREAMING_SNAKE_CASE							)
		UpperCAmelCase_			:	Any      =   False

		for i in range(_SCREAMING_SNAKE_CASE							):
			for j in range(i + 1     ,							_SCREAMING_SNAKE_CASE							):
				for k in range(j + 1     ,							_SCREAMING_SNAKE_CASE							):
					if (
					    abs(candidate[i] - candidate[j]							)
					    == abs(candidate[j] - candidate[k]							)
					    and len({candidate[i], candidate[j], candidate[k]}							) == 3
					):
						passed.append(
						    sorted([candidate[i], candidate[j], candidate[k]]							)							)
						UpperCAmelCase_			:	Optional[Any]      =   True

					if found:
						break
				if found:
					break
			if found:
				break

	UpperCAmelCase_			:	Any      =   set()
	for seq in passed:
		answer.add("".join([str(_SCREAMING_SNAKE_CASE							) for i in seq]							)							)

	return max(int(_SCREAMING_SNAKE_CASE							) for x in answer							)


if __name__ == "__main__":
					print(solution())




