(Q, S)-distance model and counting algorithms in dynamic distributed systems. (January 2018)