the second largest six-digit number in which no digit appears more than three times

largest: 999888

next: 999887