def main(): w = int(input()) d = int(input()) task = w while d >= 2: task -= task//(d**2) d -= 1 print(task) if __name__ == '__main__': main()