code: def calculate_shanten(self, tiles_34, open_sets_34=None, chiitoitsu=True, kokushi=True):
          
          # we will modify them later, so we need to use a copy
          tiles_34 = copy.deepcopy(tiles_34)
  
          self._init(tiles_34)
  
          count_of_tiles = sum(tiles_34)
  
          if count_of_tiles > 14:
              return -2
  
          # With open hand we need to remove open sets from hand and replace them with isolated pon sets
          # it will allow to calculate count of shanten correctly
          if open_sets_34:
              isolated_tiles = find_isolated_tile_indices(tiles_34)
              for meld in open_sets_34:
                  if not isolated_tiles:
                      break
  
                  isolated_tile = isolated_tiles.pop()
  
                  tiles_34[meld[0]] -= 1
                  tiles_34[meld[1]] -= 1
                  tiles_34[meld[2]] -= 1
                  tiles_34[isolated_tile] = 3
  
          if not open_sets_34:
              self.min_shanten = self._scan_chiitoitsu_and_kokushi(chiitoitsu, kokushi)
  
          self._remove_character_tiles(count_of_tiles)
  
          init_mentsu = math.floor((14 - count_of_tiles) / 3)
          self._scan(init_mentsu)
  
          return self.min_shanten
docs: Return the count of tiles before tempai
          :param tiles_34: 34 tiles format array
          :param open_sets_34: array of array of 34 tiles format
          :param chiitoitsu: bool
          :param kokushi: bool
          :return: int