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


class AlgorithmBaseOn35:

    letters = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
               'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
               'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
               'U', 'V', 'W', 'X', 'Y', 'Z']

    len1 = len(letters)

    def getLetter(self, number):
        tmp = int(number / self.len1)
        current = number % self.len1

        if tmp >= self.len1:
            return self.getLetter(tmp) + self.letters[current]
        else:
            return self.letters[tmp] + self.letters[current]

    def add(self, a, b):
        sum = a + b
        serial_number = self.getLetter(sum)
        return serial_number

    def __findLetter(self, char):
        for i in range(self.len1):
            if char == self.letters[i]:
                return i
        return -1

    def __drop0(self, text):
        char = text[0]
        if char == '0':
            return self.__drop0(text[1:])
        else:
            return text

    def to10(self, serial):
        serial = self.__drop0(serial)
        print(serial)
        len1 = len(serial)
        print(len1)
        sum = 0
        for char in serial:
            tmp = self.__findLetter(char)
            if tmp == -1:
                return None
            print(tmp)
            sum += (tmp * math.pow(35, len1 - 1))
            len1 -= 1
        return sum