def replace_u_end_day(day, year, month):
    day = day.lstrip('-')
    year = int(year)
    month = int(month.lstrip('-'))
    if day == 'uu' or day == '3u':
        return str(calendar.monthrange(year, month)[1])
    if day == '0u' or day == '1u':
        return day.replace('u', '9')
    if day == '2u' or day == 'u9':
        if month != '02' or calendar.isleap(year):
            return '29'
        elif day == '2u':
            return '28'
        else:
            return '19'
    if 1 < int(day[1]) < 9:
        return day.replace('u', '2')
    if day == 'u1':
        if calendar.monthrange(year, month)[1] == 31:
            return '31'
        else:
            return '21'
    if day == 'u0':
        if calendar.monthrange(year, month)[1] >= 30:
            return '30'
    else:
        return '20'