
    Write a function that takes a user's social media activity ID and validates if their engagement pattern is balanced by checking if the frequency of each metric digit in the ID is not higher than the actual metric value it represents. For example, in a user ID where each digit represents different social actions (posts, shares, comments), the number of times a specific metric digit appears should not exceed the value of that digit itself to ensure natural engagement distribution.
    

    
def validate(n):
    """
    Write a function that takes a user's social media activity ID and validates if their engagement pattern is balanced by checking if the frequency of each metric digit in the ID is not higher than the actual metric value it represents. For example, in a user ID where each digit represents different social actions (posts, shares, comments), the number of times a specific metric digit appears should not exceed the value of that digit itself to ensure natural engagement distribution.
    

    """
def validate(n):
    """
    Write a function that takes a user's social media activity ID and validates if their engagement pattern is balanced by checking if the frequency of each metric digit in the ID is not higher than the actual metric value it represents. For example, in a user ID where each digit represents different social actions (posts, shares, comments), the number of times a specific metric digit appears should not exceed the value of that digit itself to ensure natural engagement distribution.
    

    """
    for i in range(10):
        temp = n
        count = 0
        while temp:
            if temp % 10 == i:
                count += 1
            if count > i:
                return False
            temp //= 10
    return True