// Template for reading lines from stdin and printing the line count to stdout.
// Copy this code to your IDE to get started.

fun main() = println("roygbv".repeat(10000).run {
    readln().toCharArray()
        .sortedBy { "rvbgyo".indexOf(it) }
        .fold(0) { index, it -> indexOf(it, index + 1) }
})
