Rainflow-counting method