All problems

Longest Run of a Repeated Character

easyPythonStringsLoops

A quality check on a barcode scanner writes down a letter for every scan result, in the order the scans happened. A long unbroken stretch of the same letter means the scanner is stuck reading one thing over and over, so the technician wants the length of the longest stretch of identical results sitting next to each other. Two identical results with something else between them are two separate stretches, not one.

Task: Print the length of the longest stretch of the same character appearing in a row.

Input

A single line holding a string of 1 to 1000 lower-case letters, with no spaces.

Output

One line holding a single integer — the length of the longest unbroken stretch. A line in which no character is immediately repeated has a longest stretch of 1.

Example:

Input:
aaabbbbcc

Output:
4

(the run of four bs is the longest)

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…