Function to find the kth last element