def common_suffix(text1, text2):
    """
    Determine the common suffix of two strings.

    Args:
      text1: First string.
      text2: Second string.

    Returns:
      The number of characters common to the end of each string.
    """
    if not text1 or not text2 or text1[-1] != text2[-1]:
        return 0
    pointermin = 0
    len_text1 = len(text1)
    len_text2 = len(text2)
    pointermax = min(len_text1, len_text2)
    pointermid = pointermax
    pointerend = 0
    while pointermin < pointermid:
        if text1[-pointermid:len_text1 - pointerend] == text2[-pointermid:
            len(text2) - pointerend]:
            pointermin = pointermid
            pointerend = pointermin
        else:
            pointermax = pointermid
        pointermid = (pointermax - pointermin) // 2 + pointermin
    return pointermid
