#Activity 4.2.1

def run_length_encoding(data):
    rleCode = ""
    length = len(data)
    if length == 0:
        rleCode += ""
    elif length == 1:
        rleCode += str(length) + data
    else:
        count = 1
        index = 1
        while index < length:
        # Checks if it is the same letter.
            if data[index] == data[index - 1]: 
                count += 1
            else:
                rleCode += str(count) + data[index - 1] 
                count = 1
            index += 1
 #       rleCode += data[index - 1] + str(count)
        rleCode += str(count) + data[index - 1] 
    return rleCode

#Main program
yourData = input("Enter the data you want to compress:")
compressed = run_length_encoding(yourData)
print("\n", compressed)
