Calculate loops count