






import importlib
import os

import fsspec
import pytest
from fsspec import register_implementation
from fsspec.registry import _registry as _fsspec_registry

from datasets.filesystems import COMPRESSION_FILESYSTEMS, HfFileSystem, extract_path_from_uri, is_remote_filesystem

from .utils import require_lza, require_zstandard


def   lowerCamelCase__			(     lowercase				):

  """simple docstring"""






  assert "mock" in _fsspec_registry
  assert "bz2" in _fsspec_registry


def   lowerCamelCase__			(     ):

  """simple docstring"""






  assert "mock" not in _fsspec_registry
  assert "bz2" in _fsspec_registry


def   lowerCamelCase__			(     ):

  """simple docstring"""






  SCREAMING_SNAKE_CASE       :      Any							=    "mock-s3-bucket"
  SCREAMING_SNAKE_CASE       :      Any							=    F'''s3://{mock_bucket}'''
  SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    extract_path_from_uri(lowercase				)
  assert dataset_path.startswith("s3://"				) is False

  SCREAMING_SNAKE_CASE       :      str							=    "./local/path"
  SCREAMING_SNAKE_CASE       :      Optional[Any]							=    extract_path_from_uri(lowercase				)
  assert dataset_path == new_dataset_path


def   lowerCamelCase__			(     lowercase				):

  """simple docstring"""






  SCREAMING_SNAKE_CASE       :      Dict							=    is_remote_filesystem(lowercase				)
  assert is_remote is True

  SCREAMING_SNAKE_CASE       :      List[Any]							=    fsspec.filesystem("file"				)

  SCREAMING_SNAKE_CASE       :      Optional[int]							=    is_remote_filesystem(lowercase				)
  assert is_remote is False


@pytest.mark.parametrize("compression_fs_class"						,     lowercase				)
def   lowerCamelCase__			(     lowercase						,     lowercase						,     lowercase						,     lowercase						,     lowercase						,     lowercase						,     lowercase				):

  """simple docstring"""






  SCREAMING_SNAKE_CASE       :      Any							=    {"gzip": gz_file, "xz": xz_file, "zstd": zstd_file, "bz2": bza_file, "lz4": lza_file}
  SCREAMING_SNAKE_CASE       :      List[Any]							=    input_paths[compression_fs_class.protocol]
  if input_path is None:
    SCREAMING_SNAKE_CASE       :      List[str]							=    F'''for \'{compression_fs_class.protocol}\' compression protocol, '''
    if compression_fs_class.protocol == "lz4":
      reason += require_lza.kwargs["reason"]
    elif compression_fs_class.protocol == "zstd":
      reason += require_zstandard.kwargs["reason"]
    pytest.skip(lowercase				)
  SCREAMING_SNAKE_CASE       :      Tuple							=    fsspec.filesystem(compression_fs_class.protocol						,     fo=lowercase				)
  assert isinstance(lowercase						,     lowercase				)
  SCREAMING_SNAKE_CASE       :      List[Any]							=    os.path.basename(lowercase				)
  SCREAMING_SNAKE_CASE       :      List[Any]							=    expected_filename[: expected_filename.rindex("."				)]
  assert fs.glob("*"				) == [expected_filename]
  with fs.open(lowercase						,     "r"						,     encoding="utf-8"				) as f, open(lowercase						,     encoding="utf-8"				) as expected_file:
    assert f.read() == expected_file.read()


@pytest.mark.parametrize("protocol"						,     ["zip", "gzip"]				)
def   lowerCamelCase__			(     lowercase						,     lowercase						,     lowercase				):

  """simple docstring"""






  SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    {"zip": zip_jsonl_path, "gzip": jsonl_gz_path}
  SCREAMING_SNAKE_CASE       :      Optional[Any]							=    compressed_file_paths[protocol]
  SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    "dataset.jsonl"
  SCREAMING_SNAKE_CASE       :      List[Any]							=    F'''{protocol}://{member_file_path}::{compressed_file_path}'''
  SCREAMING_SNAKE_CASE						,  *SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    fsspec.get_fs_token_paths(lowercase				)
  assert fs.isfile(lowercase				)
  assert not fs.isfile("non_existing_" + member_file_path				)


@pytest.mark.integration
def   lowerCamelCase__			(     lowercase						,     lowercase						,     lowercase						,     lowercase				):

  """simple docstring"""






  SCREAMING_SNAKE_CASE       :      Any							=    hf_api.dataset_info(lowercase						,     token=lowercase				)
  SCREAMING_SNAKE_CASE       :      Any							=    HfFileSystem(repo_info=lowercase						,     token=lowercase				)
  assert sorted(hffs.glob("*"				)				) == [".gitattributes", "data"]
  assert hffs.isdir("data"				)
  assert hffs.isfile(".gitattributes"				) and hffs.isfile("data/text_data.txt"				)
  with open(lowercase				) as f:
    assert hffs.open("data/text_data.txt"						,     "r"				).read() == f.read()


def   lowerCamelCase__			(     ):

  """simple docstring"""






  SCREAMING_SNAKE_CASE       :      str							=    "bz2"

  # Import module
  import datasets.filesystems

  # Overwrite protocol and reload
  register_implementation(lowercase						,     lowercase						,     clobber=lowercase				)
  with pytest.warns(lowercase				) as warning_info:
    importlib.reload(datasets.filesystems				)

  assert len(lowercase				) == 1
  assert (
      str(warning_info[0].message				)
      == F'''A filesystem protocol was already set for {protocol} and will be overwritten.'''
  )









from __future__ import annotations


def   lowerCamelCase__			(     lowercase				):

  """simple docstring"""






  SCREAMING_SNAKE_CASE       :      Optional[Any]							=    str(lowercase				)
  return n == n[::-1]


def   lowerCamelCase__			(     lowercase = 1000000				):

  """simple docstring"""






  SCREAMING_SNAKE_CASE       :      int							=    0

  for i in range(1						,     lowercase				):
    if is_palindrome(lowercase				) and is_palindrome(bin(lowercase				).split("b"				)[1]				):
      total += i
  return total


if __name__ == "__main__":
   print(solution(int(str(input().strip()))))






