# How is the number of parameters k determined when calculating the AIC of an ARIMA model?

An ARIMA model is specified by 3 parameters $(p,q,d)$ or 6 (+1 for the seasonality) if we consider a seasonal ARIMA model $(p,q,d)(P,Q,D)_s$.

The AIC used to select ARIMA models is calculated by:

$AIC = N log(\frac{SSE}{N}) + 2(k+2)$

With N the number of data points, SSE the sum of the squared errors, and K the number of parameters.

How is k calculated?

Is is simply $k=3$ for a regular ARIMA model and $k=6$ for a seasonal model?

Or is k to the number of coefficients of the polynomial: For example for an ARIMA$(3,0,2)$ model, $k = 5$ ?

If it is the second case, then doesn't differencing (meaning $q,Q \neq 0$) throw off the AIC completely, since that would change the value of N?