t=p=0 for r in raw_input():n=hash(r+"VFkQW")%291*5%1254;t+=n-2*p%n;p=n print t