import TerminalIO.KeyboardReader ;

import java.util.Scanner ;

public class Wires {

public static void main ( String [ ] args ) {

@SuppressWarnings ( "unused" )

KeyboardReader reader = new KeyboardReader ( ) ;

@SuppressWarnings ( "resource" )

Scanner scanner = new Scanner ( System . in ) ;

String module ;

int length ;

System . out . print ( "Input simple wire sequence (at least 3 characters): " ) ;

module = scanner. nextLine ( ) ;

length = module. length ( ) ;

if ( length == 3 ) {

if ( module. indexOf ( 'r' ) <= 0 ) {

System . out . println ( "Cut the second wire." ) ;

}

else {

if ( module. charAt ( 2 ) == 'w' ) {

System . out . println ( "Cut the last wire." ) ;

}

else {

int counter0 = 0 ;

for ( int control0 = 0 ; control0 < module. length ( ) ; control0 ++ ) {

if ( module. charAt ( control0 ) == 'l' ) {

counter0 ++;

}

}

if ( counter0 >= 2 ) {

System . out . println ( "Cut the last blue wire." ) ;

}

else {

System . out . println ( "Cut the last wire." ) ;

}

}

}

}

else {

if ( length == 4 ) {

int counter1 = 0 ;

for ( int control1 = 0 ; control1 < module. length ( ) ; control1 ++ ) {

if ( module. charAt ( control1 ) == 'r' ) {

counter1 ++;

}

}

if ( counter1 >= 2 ) {

System . out . println ( "If the last digit of the serial number is odd, cut the last red wire. Otherwise..." ) ;

}

if ( module. charAt ( 3 ) == 'y' && counter1 == 0 ) {

System . out . println ( "Cut the first wire." ) ;

}

else {

int counter2 = 0 ;

for ( int control2 = 0 ; control2 < module. length ( ) ; control2 ++ ) {

if ( module. charAt ( control2 ) == 'l' ) {

counter2 ++;

}

}

if ( counter2 == 1 ) {

System . out . println ( "Cut the first wire." ) ;

}

else {

int counter3 = 0 ;

for ( int control3 = 0 ; control3 < module. length ( ) ; control3 ++ ) {

if ( module. charAt ( control3 ) == 'y' ) {

counter3 ++;

}

}

if ( counter3 >= 2 ) {

System . out . println ( "Cut the last wire." ) ;

}

else {

System . out . println ( "Cut the second wire." ) ;

}

}

}

}

else {

if ( length == 5 ) {

if ( module. charAt ( 4 ) == 'b' ) {

System . out . println ( "If the last digit of the serial number is odd, cut the fourth wire. Otherwise..." ) ;

}

int counter4 = 0 ;

for ( int control4 = 0 ; control4 < module. length ( ) ; control4 ++ ) {

if ( module. charAt ( control4 ) == 'r' ) {

counter4 ++;

}

}

int counter5 = 0 ;

for ( int control5 = 0 ; control5 < module. length ( ) ; control5 ++ ) {

if ( module. charAt ( control5 ) == 'y' ) {

counter5 ++;

}

}

if ( counter4 == 1 && counter5 >= 2 ) {

System . out . println ( "Cut the first wire." ) ;

}

else {

int counter6 = 0 ;

for ( int control6 = 0 ; control6 < module. length ( ) ; control6 ++ ) {

if ( module. charAt ( control6 ) == 'b' ) {

counter6 ++;

}

}

if ( counter6 == 0 ) {

System . out . println ( "Cut the second wire." ) ;

}

else {

System . out . println ( "Cut the first wire." ) ;

}

}

}

if ( length == 6 ) {

int counter7 = 0 ;

for ( int control7 = 0 ; control7 < module. length ( ) ; control7 ++ ) {

if ( module. charAt ( control7 ) == 'y' ) {

counter7 ++;

}

}

if ( counter7 == 0 ) {

System . out . println ( "If the last digit of the serial number is odd, cut the third wire. Otherwise..." ) ;

}

int counter8 = 0 ;

for ( int control8 = 0 ; control8 < module. length ( ) ; control8 ++ ) {

if ( module. charAt ( control8 ) == 'w' ) {

counter8 ++;

}

}

if ( counter7 == 1 && counter8 >= 2 ) {

System . out . println ( "Cut the fourth wire." ) ;

}

else {

int counter9 = 0 ;

for ( int control9 = 0 ; control9 < module. length ( ) ; control9 ++ ) {

if ( module. charAt ( control9 ) == 'r' ) {

counter9 ++;

}

}

if ( counter9 == 0 ) {

System . out . println ( "Cut the last wire." ) ;

}

else {

System . out . println ( "Cut the fourth wire." ) ;

}

}

}

}

}

}