fun main(args: Array<String>) {
    var count=0
    var n = readLine()!!.toInt()
    var C = readLine()!!
    for (i in 1..C.length -1) {
        if (C[i] == C[i-1]){
            count+=1
            }
        }
        print(count)
    }

import kotlin.collections.*
import kotlin.io.*
import kotlin.math.*
import kotlin.Array

class Main{

    fun solve(inp : InputReader) {
        val n = inp.readlnInt()
        val a = inp.readln()
        var i = 0
        var ans = 0
        while(i < n){
            var j = i
            while(j < n && a[i] == a[j]){
                ++j
            }
            ans += j - i - 1
            i = j
        }
        print(ans)
    }

    class InputReader{
        public fun readln() = readLine()!!
        public fun readlnInt() = readln().toInt()
        public fun readlnLong() = readln().toLong()
        public fun readlnDouble() = readln().toDouble()

        public fun readlnStrings() = readln().split(" ")
        public fun readlnInts() = readlnStrings().map{it.toInt()}
        public fun readlnLongs() = readlnStrings().map{it.toLong()}
        public fun readlnDoubles() = readlnStrings().map{it.toDouble()}
    }
}

fun main(args : Array <String>){
    Main().solve(Main.InputReader())
}

import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val stones = sc.next()
    println(removeCount(stones))
}

fun removeCount(stones: String) = (0..stones.length - 2).filter { stones[it] == stones[it+1] }.count()

import java.util.*
import kotlin.math.min

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    var stack = ' '
    val n = scanner.nextInt()
    val str = scanner.next()
    var res = 0
    (0 until n)
            .asSequence()
            .map { str[it] }
            .forEach {
                if (it == stack)
                    res++
                else
                    stack = it
            }
    print(res)
}

// kotlin oj template code from uwi(Codeforces), and convert to kotlin by lety
import java.io.ByteArrayInputStream
import java.io.IOException
import java.io.InputStream
import java.io.PrintWriter
import java.util.Arrays
import java.util.InputMismatchException
import kotlin.math.absoluteValue

lateinit var `is`: InputStream
lateinit var out: PrintWriter
var INPUT = ""

//val oj = System.getProperty("ONLINE_JUDGE") != null
val oj = true
val inbuf = ByteArray(1024)
var lenbuf = 0
var ptrbuf = 0

lateinit var cum: Array<IntArray>

fun solve()
{
    val n = ni()
    val s = ns()
    var r = 0

    for(i in 1 until n)
    {
        if( s[i] == s[i-1] )
        {
            r++
        }
    }

    println(r)
}

fun main() {
    `is` = if (oj) System.`in` else ByteArrayInputStream(INPUT.toByteArray())
    out = PrintWriter(System.out)

    val s = System.currentTimeMillis()
    solve()
    out.flush()
    tr((System.currentTimeMillis() - s).toString() + "ms")
}

private fun readByte(): Int {
    if (lenbuf == -1) throw InputMismatchException()
    if (ptrbuf >= lenbuf) {
        ptrbuf = 0
        try {
            lenbuf = `is`.read(inbuf)
        } catch (e: IOException) {
            throw InputMismatchException()
        }

        if (lenbuf <= 0) return -1
    }
    return inbuf[ptrbuf++].toInt()
}

private fun isSpaceChar(c: Int): Boolean = !(c >= 33 && c <= 126)

private fun skip(): Int {
    var b: Int = readByte()
    while (b != -1 && isSpaceChar(b)) {
        b = readByte()
    }
    return b
}

// using ns()
private fun nd(): Double = ns().toDouble()

// using ns()
private fun nc(): Char = skip().toChar()

// input until whitespace
private fun ns(): String {
    var b = skip()
    val sb = StringBuilder()
    while (!isSpaceChar(b)) { // when nextLine, (isSpaceChar(b) && b != ' ')
        sb.appendCodePoint(b)
        b = readByte()
    }
    return sb.toString()
}

private fun ns(n: Int): CharArray {
    val buf = CharArray(n)
    var b = skip()
    var p = 0
    while (p < n && !isSpaceChar(b)) {
        buf[p++] = b.toChar()
        b = readByte()
    }
    return if (n == p) buf else Arrays.copyOf(buf, p)
}

// matrix
private fun nm(n: Int, m: Int): Array<CharArray> {
    val map = Array(n) { CharArray(m) }
    for (i in 0 until n) map[i] = ns(m)
    return map
}

private fun pm(matrix: Array<CharArray>) {
    val n = matrix.size
    val m = matrix[0].size
    repeat(n)
    {
        repeat(m)
        { jt ->
            out.print(matrix[it][jt])
        }
        out.println()
    }
    out.flush()
}

// int array
private fun na(n: Int): IntArray {
    val a = IntArray(n)
    for (i in 0 until n) a[i] = ni()
    return a
}

private fun ni(): Int {
    var num = 0
    var b: Int = readByte()
    var minus = false
    while (b != -1 && !(b >= '0'.toInt() && b <= '9'.toInt() || b == '-'.toInt())) {
        b = readByte()
    }
    if (b == '-'.toInt()) {
        minus = true
        b = readByte()
    }

    while (true) {
        if (b >= '0'.toInt() && b <= '9'.toInt()) {
            num = num * 10 + (b - '0'.toInt())
        } else {
            return if (minus) -num else num
        }
        b = readByte()
    }
}

private fun nl(): Long {
    var num: Long = 0
    var b: Int = readByte()
    var minus = false
    while (b != -1 && !(b >= '0'.toInt() && b <= '9'.toInt() || b == '-'.toInt())) {
        b = readByte()
    }
    if (b == '-'.toInt()) {
        minus = true
        b = readByte()
    }

    while (true) {
        if (b >= '0'.toInt() && b <= '9'.toInt()) {
            num = num * 10 + (b - '0'.toInt())
        } else {
            return if (minus) -num else num
        }
        b = readByte()
    }
}

private fun tr(vararg o: Any) {
//    if (!oj) println(Arrays.deepToString(o))
}

import java.util.*

fun main(args: Array<String>) {
    var scan = Scanner(System.`in`)

    var cnt = scan.nextLine()
    var colors = scan.nextLine()

    var remove = 0
    var before = colors[0]
    for(i in 1 until colors.length) {
        if(before == colors[i]) {
            remove++
        } else {
            before = colors[i]
        }
    }

    println(remove)
}

fun main() {
    val stonesLength = readLine()!!.toInt()
    val stones = readLine()!!
    if (stonesLength == 1) {
        println("0")
        return
    }
    var countOfStonesTaken = 0
    for (i in 1 until stonesLength) {
        if (stones[i] == stones[i - 1]) countOfStonesTaken++
    }
    println(countOfStonesTaken)
}

import java.io.*
import java.util.*

class ProblemIO(val rd: BufferedReader, val wr: PrintWriter) {
    var tok = StringTokenizer("")

    companion object {
        fun console() = ProblemIO(BufferedReader(InputStreamReader(System.`in`)), PrintWriter(System.out))
        fun files(inputFilename: String, outputFilename: String) = ProblemIO(BufferedReader(FileReader(File(inputFilename))), PrintWriter(File(outputFilename)))
    }

    fun readToken(): String {
        while (!tok.hasMoreTokens()) {
            tok = StringTokenizer(rd.readLine())
        }
        return tok.nextToken()
    }

    fun readInt(): Int = readToken().toInt()
    fun <T> print(v: T) = wr.print(v)
    fun <T> println(v: T) = wr.println(v)
    fun close() {
        rd.close()
        wr.close()
    }
}

fun solve() {
    val io = ProblemIO.console()
    val n = io.readInt()
    val t = io.readToken()
    var res = 0
    var prev = '?'
    for (ch in t) {
        if (ch == prev) {
            res += 1
        } else {
            prev = ch
        }
    }
    io.println(res)
    io.close()
}

fun main(args: Array<String>) {
    Thread({ solve() }).start()
}

import java.io.*

/** <HEADER> **/

fun isDebug(): Boolean {
    return !System.getProperty("ONLINE_JUDGE", "False")!!.toBoolean()
}

val input = if (isDebug())
    BufferedReader(FileReader(File("input.txt")))
else
    BufferedReader(InputStreamReader(System.`in`))

/** </HEADER> **/

/** <IO_UTILS> **/

fun lineToInt(): Int {
    return input.readLine().toInt()
}

fun readLine(): String {
    return input.readLine()
}

/** </IO_UTILS> **/

fun main(args: Array<String>) {

    val n = lineToInt()
    val s = readLine().split("")

    print(s.size - s.filterIndexed { i, el -> (i == 0) || (s[i - 1] != s[i]) }.size)

}

fun main()
{
    val lens = readLine()!!.toInt()
    val word = readLine()!!
    var need = 0
    for(i in 1 until lens)
    {
        if (word[i] == word[i - 1]) need ++

    }
    println(need)
}

fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    val len = r.readLine()!!.toInt()
    val str = r.readLine()!!
    val x = (1..len-1).fold(0){acc, i -> acc + if (str[i]==str[i-1]) 1 else 0 }
    println(x)
}

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val C = readLine()!!
    var c = 0
    for (i in 1..C.length -1) {
        if (C[i] == C[i-1]){
            c++
        }
    }
    print(c)
}

fun main(args: Array<String>) {
    var c = 0
    val n = readLine()!!.toInt()
    val a = readLine()!!.split("")
    for (i in 0 until n) {
        if (a[i] == a[i + 1])
            c++
    }
    print(c)
}

fun main(args: Array<String>) {
    // Omit first line
    readLine()

    val stones = readLine()!!
    var subs = 0
    for (i: Int in (1 until stones.length)) {
        if (stones[i] == stones[i-1]) subs ++
    }
    println(subs)
}

fun main(args: Array<String>){
    val length = readLine()?.toInt()
    val input = readLine()

    var result : Int = 0

    fun check(index: Int , c : Char){
        if (index <= length!!-2 && c == input?.get(index+1)){
            result++
        }
    }

    input?.forEachIndexed { index, c -> check(index , c) }
    println(result)

}

import java.util.*
import java.util.regex.Pattern

fun main(args: Array<String>) {

    var len = readLine()!!
    var text = readLine()!!
    var count = 0
    if (Pattern.matches("[A-Z]+", text))
    {
        for (i in 0..(len.toInt() - 1))
        {
            if (i==(len.toInt() - 1))
                break
            if (text[i] == text[i + 1])
            {
                count++
            }

        }

        print(count)

    }

}

fun main() {
    var result = 0
    val count = readLine()!!.toInt()
    val input = readLine()!!.split("")

    for (i in 0 until count) {
        val nextStone = input.getOrNull(i + 1)
        val currentStone = input[i]

        if ((nextStone != null) and (currentStone == nextStone)) {
            result += 1
        }
    }

    print(result)
}

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main() {
    readLn()
    println(readLn().zipWithNext().count { (a, b) -> a == b })
}

import java.io.PrintWriter
import java.util.StringTokenizer
import kotlin.math.pow
import kotlin.math.sqrt

//private val INPUT = File("input.txt").inputStream()
//private val OUTPUT = File("output.txt").outputStream()
private val INPUT = System.`in`
private val OUTPUT = System.out

private val bufferedReader = INPUT.bufferedReader()
private val outputWriter = PrintWriter(OUTPUT, false)
private fun readLn() = bufferedReader.readLine()!!

private fun readList() = readLn().split(' ')
private var tokenizer = StringTokenizer("")
private fun read(): String {
    while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(readLn(), " ")
    return tokenizer.nextToken()
}

private fun readInt() = read().toInt()
private fun readLong() = read().toLong()
private fun readDouble() = read().toDouble()

private fun readIntList() = readList().map { it.toInt() }
private fun readLongList() = readList().map { it.toLong() }
private fun readDoubleList() = readList().map { it.toDouble() }

private fun readIntArray(n: Int = 0) =
    if (n == 0) readList().run { IntArray(size) { get(it).toInt() } } else IntArray(n) { readInt() }

private fun readLongArray(n: Int = 0) =
    if (n == 0) readList().run { LongArray(size) { get(it).toLong() } } else LongArray(n) { readLong() }

private fun readDoubleArray(n: Int = 0) =
    if (n == 0) readList().run { DoubleArray(size) { get(it).toDouble() } } else DoubleArray(n) { readDouble() }

private fun Int.modPositive(other: Int): Int = if (this % other < 0) ((this % other) + other) else (this % other)

private class `CF266-D2-A` {
    fun solveTestCase(): Int {
        val n = readInt()
        val s = read()

        var prev = s[0]
        var count = 0
        for (i in 1 until n) {
            if (s[i] == prev) count++
            else prev = s[i]
        }

        return count
    }
}

fun main(args: Array<String>) {

    outputWriter.println(
        `CF266-D2-A`()
            .solveTestCase()
    )

    outputWriter.flush()
}

fun main(args: Array<String>) {
    readLine()
    var answer = 0
    val input: String = readLine()!!
    var currentChar = input.first()
    input.forEachIndexed { index, char ->
        if (index > 0) {
            if (char.equals(currentChar)) {
                answer += 1
            }
        }
        currentChar = char
    }
    println(answer)
}

fun String.countIndexed(predicate: (index: Int, ch: Char) -> Boolean): Int {
    var count = 0
    forEachIndexed { index, ch -> if (predicate(index, ch)) count++ }
    return count
}

fun main() = Pair(readLine()!!, readLine()!!)
    .let { (_, stones) ->
        stones.countIndexed { index, ch -> ch == stones.getOrNull(index - 1) }
    }
    .run(::println)

fun main(args: Array<String>) {
    val t = readInt()
    val str = readLine()!!
    var counter = 0
    var prev = str[0]
    str.substring(1).forEach { c ->
        if (prev == c) counter++
        prev = c
    }
    println(counter)
}

private fun readInt() = readLine()!!.toInt()

    fun main(args: Array<String>) {
        var count = readLine()!!.toInt()
        var num = 0
        var input = readLine()!!
        for (i in 1 until input.length){
            if (input[i-1] == input[i]) ++num
        }
        println(num)
    }

import java.util.Scanner;
import java.util.Arrays;
import java.util.*;
import java.math.*;
import java.io.*;

fun main(args: Array<String>) {
    var s = Scanner(System.`in`)
    var numberofstones= s.nextInt()
   neighboring(numberofstones,s)

}

fun neighboring( numberofstones:Int ,  s:Scanner){
    var colors = s.next()
    var color = colors.toCharArray()
    var number = 0
    for(i in color.indices){
     if(i!=numberofstones-1){

     if(color[i]==color[i+1]){
     number++

    }

    }

}
print(number)
}

import java.util.Scanner;
import java.util.Arrays;
fun main(args: Array<String>) {
val s = Scanner (System.`in`);
val a : Int = s.nextInt();
val b : String = s.next();
val c = b.toCharArray();
var d = 0 ;
for(i in 0 until a){
if(i < a-1){
 if ( c[i] == c[i+1]){
 d++

 }
 }
 }
 println(d);
}

import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val reader = Reader()
    reader.nextInt()
    val string = reader.next()
    var lastCharacter = ' '
    var count = 0
    for (i in 0 until string.length) {
        val char = string.elementAt(i)
        if (char.equals(lastCharacter))
            count++
        lastCharacter = char
    }
    println(count)

}

internal class Reader {
    var br: BufferedReader
    var st: StringTokenizer? = null

    init {
        br = BufferedReader(InputStreamReader(System.`in`))
    }

    operator fun next(): String {
        while (st == null || !st!!.hasMoreElements()) {
            try {
                st = StringTokenizer(br.readLine())
            } catch (e: IOException) {
                e.printStackTrace()
            }

        }
        return st!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }

    fun nextLine(): String {
        var str = ""
        try {
            str = br.readLine()
        } catch (e: IOException) {
            e.printStackTrace()
        }

        return str
    }
}

import java.io.*
import java.util.*

fun main(args: Array<String>) {
    val inputStream = System.`in`
    val outputStream = System.out
    val input = InputReader(inputStream)
    val output = PrintWriter(outputStream)
    val solver = Task()
    solver.solve(input, output)
    output.close()
}

private class Task {
    fun solve(input: InputReader, output: PrintWriter) {
        input.next()
        val str = input.next()

        if (str.length == 1) {
            output.print(0)
            return
        }

        var top = str.first()
        var result = 0

        for (index in 1 until str.length) {
            if (top != str[index]) {
                top = str[index]
            } else {
                result++
            }
        }

        output.print(result)
    }
}

private class InputReader(stream: InputStream) {
    private var reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer? = null

    operator fun next(): String {
        while (tokenizer == null || tokenizer?.hasMoreTokens()?.not() == true) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }
}

/* http://codeforces.com/problemset/problem/266/A */

fun main() {
    readLine() // skip first line
    var removeCount = 0
    val string = readLine()!!
    var lastChar = string[0]
    for (i in 1 until string.length) {
        if (lastChar == string[i]) {
            removeCount++
        }
        lastChar = string[i]
    }
    println(removeCount)
}

import java.lang.StringBuilder

fun main(){
    var num = readLine()
    var stones = StringBuilder(readLine())
    println(answer(stones))
}

fun answer (stones:StringBuilder):Int{
    var num = 0
   for(i in 1 until stones.length){
       if(stones.get(i) == stones.get(i-1))
           num++
   }
    return num
}

fun main(args: Array<String>)
{
    val n = readLine()!!.toInt()
    var s = readLine()!!
    var result: Int = 0
    for (i in 1..s.length - 1)
    {
        if (s[i] == s[i - 1]) ++result
    }
    println(result)
}

fun main(args: Array<String>) {
    var count=0
    var n = readLine()!!.toInt()
    var C = readLine()!!
    for (i in 1..C.length -1) {
        if (C[i] == C[i-1]){
            count++
            }
        }
        print(count)
    }

import java.util.*

    fun main(args: Array<String>)
    {
        val `in` = Scanner(System.`in`)
        val n = `in`.nextInt()
        val arr: CharArray
        `in`.nextLine()
        val str = `in`.nextLine()
        arr = str.toCharArray()
        val s = Stack<Char>()
        var count = 0
        for (i in arr.indices)
        {
            if (s.isEmpty())
            {
                s.push(arr[i])
            }
            else
            {
                if (s.peek() == arr[i])
                {
                    if (!s.isEmpty())
                    {
                        count++
                    }
                    else
                    {
                        count++
                    }
                }
                else
                {
                    s.push(arr[i])
                }
            }
        }
        println(count)
    }

fun main() {

    val count = readLine()

    val colors = readLine().toString()

    var haveToMove = 0
    colors.toCharArray().apply {
        forEachIndexed { index, c ->

            if (index != size - 1) {

                if (c == this[index + 1]) {
                    haveToMove++
                }

            }
        }
    }

    println(haveToMove)

}

import java.util.*

fun main(args: Array<String>) {
    val s: Scanner = Scanner(System.`in`)
    val n: Int = s.nextInt()
    val str: String = s.next()
    var prevC: Char = ' '
    var result: Int = 0
    for (c in str) {
        if (c == prevC) {
            result++
        }
        prevC = c
    }
    println(result)
}

fun main(args: Array<String>) {

    readLine()!!.toInt()
    val rgb: CharArray = readLine()!!.toCharArray()
    print((1 until rgb.size)
            .count { rgb[it] == rgb[it - 1] })
}

import java.io.BufferedReader
import java.io.FileInputStream
import java.io.InputStreamReader

fun main(args: Array<String>) {
    val reader = BufferedReader(InputStreamReader(System.`in`))
    reader.use {
        var el = it.readLine()
        el = it.readLine()
        var last:Char? = null
        var count = 0
        for (ch in el) {
            if(last == ch ){
                count++
            }
            last = ch
        }
        print(count)
    }
}

fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val stones= readLine()!!.toString()
    var count=1
    var j=1
    val size=n-1
    for (i in 0 until size)
    {

        if (stones[i]==stones[j])
        {
            count++
        }
        j++
    }
    print(count-1)
}

import java.util.Scanner

fun main(args: Array<String>) {
  Scanner(System.`in`).use {
    val length = it.nextInt()
    val colorSequence = it.next()

    var twoConsecutiveColorCount = 0
    var previousColor = colorSequence[0]
    for (i in 1 until length) {
      val currentColor = colorSequence[i]
      if (currentColor != previousColor) {
        previousColor = currentColor
        continue
      }
      ++twoConsecutiveColorCount
    }
    println(twoConsecutiveColorCount)
  }
}

fun main() {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    var count = 0
    for (i in 1 until n) {
        if (s[i - 1] == s[i]) {
            count++
        }
    }
    println(count)
}

// codeforces problem 266 A

fun main() {
    readLine()!!
    println(readLine()!!.zipWithNext().count { (a, b) -> a == b })
}

fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var str = readLine()!!.toString()
    var count = 0
    for (i in 0 until str.length-1){
        if (str[i]==str[i+1]){
            count++
        }
    }
    println(count)
}

fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val line = readLine()!!
    var ans = 0
    var c = 0
    for (i in 1..(n-1)) {
        if (line[i] == line[i-1])
            c++
        else{
            ans += c
            c = 0
        }
    }
    ans += c
    println(ans)
}

import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    scanner.nextLine()
    val stones = scanner.nextLine()

    var result = 0
    var stoneIndex = 0
    while(stoneIndex < stones.length - 1) {
        if(stones[stoneIndex ] == stones[stoneIndex+1]) {
            result++
        }
        stoneIndex++
    }

    println(result)
}

// https://codeforces.com/problemset/problem/266/A

fun main(args: Array<String>) {
    val n = readInt()
    val data = readLn()
    var actualCharacter: Char = '0'
    var numberToDelete = 0;
    for (character in data) {
        if (actualCharacter == '0') {
            actualCharacter = character;
        } else {
            if (actualCharacter == character) {
                numberToDelete++
            } else {
                actualCharacter = character
            }
        }
    }
    print(numberToDelete)
}

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings(del: String = " ") = readLn().split(del) // list of strings
private fun readInts(del: String = " ") = readStrings(del).map { it.toInt() } // list of ints

import java.util.*

fun main(args: Array<String>) {
        val scan = Scanner(System.`in`)
        val n = scan.nextInt()
        val str = scan.next()

        var prev = str.first()
        var ans = 0

        for(i in 1 until str.length) {
                if(str[i] == prev) {
                        ans++
                }
                prev = str[i]
        }
        println(ans)
}

import java.io.BufferedReader
import java.io.InputStreamReader
import java.lang.StringBuilder

fun main() {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val n = br.readLine()
    val s = br.readLine()
    val contigs = s.fold(ArrayList<StringBuilder>()){
        acc, c -> acc.apply {
            if (isEmpty() || last().last() != c){
                add(StringBuilder(c.toString()))
            } else {
                last().append(c)
            }
        }
    }
    println(
        contigs.fold(0){
            acc, block -> acc + block.length - 1
        }
    )
}

import java.util.*

fun main() {
    val reader = Scanner(System.`in`)
    val n = reader.nextInt()
    reader.nextLine()
    val word = reader.nextLine()
    var m = 0
    var init = word[0]
    for (i in 1 until word.length){
        if (init == word[i]) {
            m++
        }
        init = word[i]
    }

    println(m)
}

//package problem266A

fun containsDuplicateNeighbors(stones: List<Char>): Boolean {
    for (i in 0 until stones.size - 1) {
        if (stones[i] == stones[i + 1]) {
            return true
        }
    }

    return false
}

fun removeDuplicateNeighbors(stones: MutableList<Char>): Int {
    var numRemoved = 0
    for (i in stones.size - 1 downTo 1) {
        if (stones[i] == stones[i - 1]) {
            stones.removeAt(i)
            ++numRemoved
        }
    }
    return numRemoved
}

fun main() {
    readLine()!!
    val stones = readLine()!!.toMutableList()
    var numRemoved = 0

    while (containsDuplicateNeighbors(stones)) {
        numRemoved += removeDuplicateNeighbors(stones)
    }

    println(numRemoved)
}

import java.lang.StringBuilder

fun readLn() = readLine()!! // string line
fun readInt() = readLn().toInt() // single int
fun readStrings() = readLn().split(" ") // list of strings
fun readInts() = readStrings().map { it.toInt() } // list of ints

fun minNumberOfStones(): Int {
    val n = readInt()
    val stonesColors = readLn()

    var nwDistinctStones: StringBuilder = StringBuilder()
    nwDistinctStones.append(stonesColors[0])

    for (i in 1 until stonesColors.length)
        if (stonesColors[i] != nwDistinctStones[nwDistinctStones.lastIndex])
            nwDistinctStones.append(stonesColors[i])

    return stonesColors.length - nwDistinctStones.length
}

fun main() {
    print(minNumberOfStones())
}

import java.util.*

fun main()
{
    var scanner = Scanner(System.`in`)
    var number = scanner.next().toInt()
    var str = scanner.next()
    var counter = 0
    for(i in 0 until str.length-1)
    {
        if(str[i] == str[i+1])
            counter++
    }
    println(counter)
}

import java.util.*
fun main() {
    val sc = Scanner(System.`in`)

    var n = sc.nextInt()
    var s = sc.next()
    var k = 0
    for(i in 0 until n-1){
        if(s[i] == s[i+1]){
            k++
        }
    }
    print(k)
}

import java.util.Scanner
import java.util.Set
import java.util.LinkedHashSet

import java.util.*
fun main() {
    val s = Scanner(System.`in`)
    val size = s.nextInt()
    var x = 0
    var str = s.next()
    val arr = str!!.toCharArray()
    for (i in 0 until size-1) {
        if (arr[i] == arr[i + 1])
            x++
    }
    print(x)

}

fun main() {
    readLine()
    var a: String = readLine()!!
    var ans: Int = 0
    for (i in 1 until a.length){
        if (a[i] == a[i - 1]){
            ++ans
        }
    }
    print(ans)
}

fun main(args: Array<String>) {
    readLine()!!
    val line = readLine()!!
    println(line.fold(0 to 'X', { acc, c -> (if (c == acc.second) acc.first + 1 else acc.first) to c }).first)
}

import java.util.*

fun main(args: Array<String>){
    val scan = Scanner(System.`in`)
    val n = scan.nextInt()
    val s = scan.next()
    var c = 0

    for (i in 0 until n-1){
        if (s[i] == s[i+1]) c++
    }
    println(c)
}

fun main() {
    readLine()
    var chars = readLine()!!.toCharArray()
    var ans = 0
    for (i in 1..chars.lastIndex) {
        if (chars[i] == chars[i - 1])
            ans++
    }
    println(ans)
}

fun main() {
    val n = readLine()
    val str = readLine()!!
    println(str.length -
            repl(repl(repl(str, "RR", "R"), "GG", "G"),"BB", "B")
                .length)
}

fun repl(s: String, subs: String, repl: String): String {
    var str = s
    while (str.contains(subs, true))
        str = str.replace(subs, repl, true)
    return str
}

import java.lang.AssertionError
import java.util.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

private fun myAssert(x: Boolean) {
    if (!x) {
        throw AssertionError()
    }
}

fun main(args: Array<String>) {
//  var s = Scanner(System.`in`)
  var n = readInt()
  var s = readLn()
  var ans = 0
  for (i in 1 until s.length) {
    if (s[i - 1] == s[i])
      ans++
  }
  println(ans)
}

fun main()
  {
   val s:String
    var count :Int=0
    var n:Int
    n= readLine()!!.toInt()
    s= readLine()!!.toString()
    for(i in s.indices)
    {
         if(i<s.length-1)
         {
           if (s[i]==s[i+1])
           {
             count++
           }
         }
    }
    print(+count)
  }

fun main(args: Array<String>) {
  readLine()!!.toInt()
  val stones = readLine()!!.toCharArray()
  println((1 until stones.size).count{stones[it] == stones[it - 1]})
}

fun main(){
    val n = readLine()!!.toInt()
    val s = readLine()!!
    var count = 0
    for (i in 0..n-2){
        if (s[i].compareTo(s[i+1]) == 0) count++
    }
    println(count)
}

import java.lang.StringBuilder

fun main() {

    solve266A()

}

fun solve266A() {

    val countString = readLine()

    val inputValue = readLine()

    var count = 0

    if (inputValue == null) {
        return
    }

    val result: StringBuilder = StringBuilder()

    inputValue.forEach {
        if (result.length == 0 || result.last() != it) {
            result.append(it)
        }
    }

    println(inputValue.length - result.length)

}

import java.util.Scanner

fun main(args:Array<String>){
    val input = Scanner(System.`in`)
    var n = input.nextInt()
    var str = input.next()
    var count = 0

    for(i in 0 until n-1){
        if(str[i] == str[i+1]){
            count += 1
        }
    }
    print(count)
}

fun main() {
        val c = readLine()!!
        val s = readLine()!!

        var p = s[0]
        var r = -1
        s.forEach {
            if(it.equals(p)) {
                r++
            }
            p = it
        }
        println(r)
    }

fun main(){
    var n = readLine()!!.toInt();
    var a = readLine()!!.toString();
    var tot=0;
    for(i in 1..(n-1)) if(a[i]==a[i-1]) tot+=1;
    println(tot);
}

fun main(args: Array<String>) {
    val quantity = Integer.parseInt(readLine())
    val colors = readLine()
    print(findColor(colors, quantity))
}

fun findColor(colors : String?, quantity : Int) : Int {
    var find = 0
    for(i in 1 until quantity){
        if(colors!![i].equals(colors[i-1])) find++
    }
    return find
}

import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)

    val n: Int = scanner.nextInt()
    val str: String = scanner.next()

    var last = str[0]; var cnt = 0
    for(i in 1 until n){
        cnt += if(last == str[i]) 1 else 0
        last = str[i]
    }

    print(cnt)
}

import java.util.*

private val scan = Scanner(System.`in`)

fun main(args: Array<String>) {
    scan.nextInt()
    val s = scan.next()
    val set = mutableListOf<Char>()
    var ans = 0

    s.forEach { if (it != set.lastOrNull()) set.add(it) else ans++ }

    println(ans)
}

import java.io.BufferedReader
import java.io.InputStreamReader

fun main(args: Array<String>) {
    val reader = BufferedReader(InputStreamReader(System.`in`))
    reader.readLine()!!
    val array = reader.readLine().toCharArray()
    var count = 0
    var buffer: Char = array.first()
    val iterator = array.iterator()
    iterator.nextChar()
    while (iterator.hasNext()) {
        val char = iterator.nextChar()
        if (char == buffer) {
            count++
        } else {
            buffer = char
        }
    }
    println(count)
}

fun main() {
    readLine()!!
    var count = 0
    readLine()!!.toCharArray().let {
        var cur = it[0]
        for((i, c) in it.withIndex()) {
            if(i == 0) {
                continue
            }
            if(c == cur)
                count++
            else
                cur = c
        }
    }
    println(count)
}

fun main() {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    val filtered = s.filterIndexed { index, c ->
        when (index) {
            0 -> true
            else -> c != s[(index + n - 1) % n]
        }
    }
    println(s.length - filtered.length)
}

fun main() {
    val numOfcolors = readLine()
    val colors = readLine()
    var toRemove = 0
    for(i in 0 until (colors?.length!!-1)!!){
        if(colors.get(i) == colors.get(i+1)){
            toRemove+=1
        }
    }
    println(toRemove)
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    var ans: Int = 0
    for (i in 1..n-1) {
        if (s[i] == s[i-1])
            ans++
    }
    print(ans.toString() + "\n")
}

fun main(args: Array<String>) {
    readLine()
    println(
        Regex("R{2,}|G{2,}|B{2,}").findAll(readLine()!!)
                .sumBy { it.value.length - 1 }
    )
}

fun main() {

    val n = readLine()!!.toInt()
    val row = readLine()!!
    var count = 0

    row.forEachIndexed{ index, _ ->
        if(index != row.lastIndex)
            if(row[index] == row[index+1])
                count++
    }

    print(count)
}

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main() {
    readLn()
    val balls = readLn()

    if (balls.length <= 1) {
        println(0)
        return
    }

    var res = 0
    balls.reduce { a, b -> if (a == b) ++res; b }

    println(res)
}

import Output.print
import Output.println
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs

object Input {

    private val input = BufferedReader(InputStreamReader(System.`in`))
    private lateinit var tokenizer: StringTokenizer

    val next: String get() = input.readLine()
    val intValue get() = next.toInt()
    val longValue get() = next.toLong()
    val floatValue get() = next.toFloat()
    val doubleValue get() = next.toDouble()

    val intList get()= valuesList { it.toInt() }
    val longList: List<Long> get() = valuesList { it.toLong() }
    val floatList: List<Float> get() = valuesList { it.toFloat() }
    val doubleList: List<Double> get() = valuesList { it.toDouble() }

    private inline fun <T> valuesList(f: (String) -> T): List<T> = mutableListOf<T>().apply {
        tokenizer = StringTokenizer(input.readLine())
        while (tokenizer.hasMoreTokens()) add(f(tokenizer.nextToken()))
    }

    fun close() = input.close()
}

object Output {

    private val output = PrintWriter(System.out)

    fun Number.print() = output.print(this)

    fun Number.println() = output.println(this)

    fun String.print() = output.print(this)

    fun String.println() = output.println(this)

    fun List<Number>.print(delimiter: CharSequence = " ") = output.print(this.joinToString(delimiter))

    fun List<Number>.println(delimiter: CharSequence = " ") = output.println(this.joinToString(delimiter))

    fun flush() = output.flush()

    fun close() = output.close()
}

fun close() {
    Output.flush()
    Input.close()
    Output.close()
}

fun solve() {
    val n = Input.intValue
    val a = Input.next
    a.takeLast(n-1).filterIndexed { index, c -> a[index] == c }.length.print()
}

fun main() {
//    var tt = Input.intValue
//    while (tt-- != 0) {
        solve()
//    }
    Output.flush()
}

fun main(args: Array<String>) {
    var counter = 0
    val stoneCount = readLine()!!.toInt()
    val stones = readLine()!!
    for (i in 1 until stoneCount) {
        if (stones[i - 1] == stones[i]) {
            counter ++
        }
    }

    println(counter)
}

import java.util.Scanner

fun main(){
    var input = Scanner(System.`in`)
    var num = input.next()
    var s = input.next()
    println(checkNeighborSame(s))
}
fun checkNeighborSame(str : String) : Int {

    var res = 0;
    var charArr = str.toCharArray()
    var arr = arrayListOf<Char>()
    for (i in 0..charArr.size-1){
        arr.add(charArr.get(i))
    }
    var i = 0
    while (i < arr.size-1){
        if(arr.get(i) == arr.get(i+1)) {
            arr.removeAt(i+1)
            res++
        }else
            i++
    }
    return res

}

import java.util.*

fun main() {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val c = scanner.next()

    var take = 0
    for (i in 0 until n - 1) {
        if (c[i] == c[i + 1]) {
            take += 1
        }
    }

    println(take)
}

fun main() {
    val stones = readLine()!!.toInt()
    val data = readLine()!!.map { it.toString() }

    val clean = data.reduce { acc, s ->
        if (acc.last().toString() == s) acc else acc + s
    }
    println(stones - clean.length)
}

fun main() {
    val n = readLine()!!.toInt()
    var stones = readLine()!!.toCharArray()
    var tbr = 0
    var latest = stones[0]
    for (i in 0 until n - 1) {
        if (latest == stones[i + 1]) {
            tbr++
            stones[i + 1] = ' '
        }
        else {
            latest = stones[i + 1]
        }
    }
    print(tbr)
}

fun main() {
    val stonesLength = readLine()!!.toInt()
    val stones = readLine()!!
    if (stones.length == 1) {
        println("0")
        return
    }
    var countOfStonesTaken = 0
    var compareIndex = 0
    var currentIndex = 1
    while (currentIndex < stonesLength) {
        if (stones[compareIndex] == stones[currentIndex]) {
            countOfStonesTaken++
        } else compareIndex++
        currentIndex++
    }
    println(countOfStonesTaken)
}

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main() {
    println(readLn().zipWithNext().count { (a, b) -> a == b })
}

import java.util.Scanner
import java.util.Set
import java.util.LinkedHashSet

import java.util.*
fun main() {
    val s = Scanner(System.`in`)
    val size = s.nextInt()
    var x = 0
    var userInput = readLine()
    var str = "$userInput".take(size)
    val arr = str.toCharArray()
    for (i in 0 until size) {
        if (i == size - 1) break
        if (arr[i] == arr[i + 1])
            x++
    }
    print(x)

}

fun main() {
    var a: String = readLine()!!
    var ans: Int = 0
    for (i in 1 until a.length){
        if (a[i] == a[i - 1]){
            ++ans
        }
    }
    print(ans)
}

fun main() {
        val c = readLine()!!
        val s = readLine()!!

        var p = s[0]
        var r = 0
        s.forEach {
            if(it.equals(p)) {
                r++
            }
            p = it
        }
        println(r)
    }

import java.io.BufferedReader
import java.io.InputStreamReader

fun main(args: Array<String>) {
    val reader = BufferedReader(InputStreamReader(System.`in`))
    reader.readLine()!!
    val array = reader.readLine().toCharArray()
    var count = 0
    var buffer: Char? = null
    for (char in array) {
        if (buffer == null) {
            buffer = char
        } else if (buffer == char) {
            count++
        } else if (buffer != char) {
            buffer = null
        }
    }
    println(count)
}

import kotlin.math.max

fun main() {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    val filtered = s.filterIndexed { index, c ->
        c != s[(index + n - 1) % n]
    }
    println(s.length - max(filtered.length, 1))
}