# coding: utf-8 import array, bisect, collections, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) inf = 10 ** 20 mod = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): return {key: value for key, value in ILI()} def make_prime_list(num): if num < 2: return [] # 0のものは素数じゃないとする prime_list = [i for i in range(num + 1)] prime_list[1] = 0 # 1は素数ではない num_sqrt = math.sqrt(num) for prime in prime_list: if prime == 0: continue if prime > num_sqrt: break for non_prime in range(2 * prime, num, prime): prime_list[non_prime] = 0 return [prime for prime in prime_list if prime != 0] def search_divisor_num_1(num): if num < 0: return None elif num == 1: return 1 else: num_sqrt = math.floor(math.sqrt(num)) prime_list = make_prime_list(num_sqrt) divisor_num = 1 for prime in prime_list: count = 1 while num % prime == 0: num //= prime count += 1 divisor_num *= count if num != 1: divisor_num *= 2 return divisor_num def solve(N, p): ans = 0 for n in range(2, N + 1): ans += (1 - p) ** (search_divisor_num_1(n) - 2) return ans def main(): N, p = input().split() print(solve(N, p)) if __name__ == "__main__": main()