solve frequency.py