# -*- coding: utf-8 -*- W = int(input()) D = int(input()) while 1 < D: W -= W // D**2 D -= 1 print(W)