def validate(n):
    s = str(abs(n))
    counts = {}
    for ch in s:
        counts[ch] = counts.get(ch, 0) + 1
    for d in "0123456789":
        if counts.get(d, 0) > int(d):
            return False
    return True