The length command computes the length of the top level of an expression A. Square brackets can be used to index the parts of an expression from 0 to length-1.
f = x^2+x+1; f; 1+x+x^2 length(f); 3 f[0]; f[1]; f[2]; 1 x x^2