solution for rightmost character