Check if the character is on left side of window find the cost of modification for character add value to count calculate nearest distance of modification
if ( $ j >= $ a && $ j >= $ b ) $ count = $ count + ( min ( $ j - $ b , 25 - $ j + $ a + 1 ) ) * $ cnt [ $ j ] ;