def find_piece_size(total_size):
    """ Determine the ideal piece size for a torrent based on the total
    size of the data being shared.

    :param total_size: Total torrent size
    :type total_size: int
    :return: Piece size (KB)
    :rtype: int
    """
    if total_size <= 2 ** 19:
        return 512
    elif total_size <= 2 ** 20:
        return 1024
    elif total_size <= 2 ** 21:
        return 2048
    elif total_size <= 2 ** 22:
        return 4096
    elif total_size <= 2 ** 23:
        return 8192
    elif total_size <= 2 ** 24:
        return 16384
    else:
        raise ValueError("Total size is unreasonably large")