calculating longest sreak