consider all integer combinations of ab for 2 a 5 and 2 b 5 224 238 2416 2532 329 3327 3481 35243 4216 4364 44256 451024 5225 53125 54625 553125 if they are then placed in numerical order with any repeats removed we get the following sequence of 15 distinct terms 4 8 9 16 25 27 32 64 81 125 243 256 625 1024 3125 how many distinct terms are in the sequence generated by ab for 2 a 100 and 2 b 100 returns the number of distinct terms in the sequence generated by ab for 2 a 100 and 2 b 100 solution100 9183 solution50 2184 solution20 324 solution5 15 solution2 1 solution1 0 returns the number of distinct terms in the sequence generated by a b for 2 a 100 and 2 b 100 solution 100 9183 solution 50 2184 solution 20 324 solution 5 15 solution 2 1 solution 1 0 maximum limit calculates the current power adds the result to the set
def solution(n: int = 100) -> int:
    
    collect_powers = set()

    current_pow = 0

    n = n + 1  

    for a in range(2, n):
        for b in range(2, n):
            current_pow = a**b  
            collect_powers.add(current_pow)  
    return len(collect_powers)


if __name__ == "__main__":
    print("Number of terms ", solution(int(str(input()).strip())))