code: def button_count(self):
          
          if self._buttons_count is None:
              if isinstance(self.reply_markup, (
                      types.ReplyInlineMarkup, types.ReplyKeyboardMarkup)):
                  self._buttons_count = sum(
                      len(row.buttons) for row in self.reply_markup.rows)
              else:
                  self._buttons_count = 0
  
          return self._buttons_count
docs: Returns the total button count.