N, M = gets.split.map &:to_i
dp = 1, *[0] * N
(N-1).times do |j|
  k = (j + 3) / 2
  (N-k).times do |i|
    dp[i+k] = (dp[i+k] + dp[i] % M) % M
  end
end
ans = 0
N.times do |i|
  ans = (ans + dp[i] * (N - i)) % M
end
p ans % M

__END__

1 2 2 3 3 4 4 ... (N-1個)
