Could the Input shape of the LSTM layer not be a constant?
That line doesn't work because the architecture of ANNs must be kept constant, in order to train them. If you vary the number of input cells, you change the architecture of the ANN itself.

If your input sequences are not of constant length, I suggest you to use zero padding. This is the most common and used padding technique. In other words, you "complete" the input series with zeros at the end, so that they all have the same length. A properly defined Neural Network would then learn to ignore the zeros and capture only the relvant information.

You can read more about padding here.