Arpa is taking a geometry exam. Here is the last problem of the exam.You are given three points a, b, c.Find a point and an angle such that if we rotate the page around the point by the angle, the new position of a is the same as the old position of b, and the new position of b is the same as the old position of c.Arpa is doubting if the problem has a solution or not (i.e. if there exists a point and an angle satisfying the condition). Help Arpa determine if the question has a solution or not.

The only line contains six integers ax, ay, bx, by, cx, cy (|ax|, |ay|, |bx|, |by|, |cx|, |cy| ≤ 109). It's guaranteed that the points are distinct.

Print "Yes" if the problem has a solution, "No" otherwise. You can print each letter in any case (upper or lower).

NoteIn the first sample test, rotate the page around (0.5, 0.5) by .In the second sample test, you can't find any solution.

import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val ax = sc.nextLong()
    val ay = sc.nextLong()
    val bx = sc.nextLong()
    val by = sc.nextLong()
    val cx = sc.nextLong()
    val cy = sc.nextLong()

    val d1 = (bx - ax) * (bx - ax) + (by - ay) * (by - ay)
    val d2 = (cx - bx) * (cx - bx) + (cy - by) * (cy - by)

    when {
        Math.abs((bx - ax) * (cy - ay)) == Math.abs((by - ay) * (cx - ax)) -> println("No")
        d1 != d2 -> println("No")
        else -> println("Yes")
    }

}


A permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array) and $$$[1,3,4]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).Consider a permutation $$$p$$$ of length $$$n$$$, we build a graph of size $$$n$$$ using it as follows:   For every $$$1 \leq i \leq n$$$, find the largest $$$j$$$ such that $$$1 \leq j < i$$$ and $$$p_j > p_i$$$, and add an undirected edge between node $$$i$$$ and node $$$j$$$  For every $$$1 \leq i \leq n$$$, find the smallest $$$j$$$ such that $$$i < j \leq n$$$ and $$$p_j > p_i$$$, and add an undirected edge between node $$$i$$$ and node $$$j$$$ In cases where no such $$$j$$$ exists, we make no edges. Also, note that we make edges between the corresponding indices, not the values at those indices.For clarity, consider as an example $$$n = 4$$$, and $$$p = [3,1,4,2]$$$; here, the edges of the graph are $$$(1,3),(2,1),(2,3),(4,3)$$$.A permutation $$$p$$$ is cyclic if the graph built using $$$p$$$ has at least one simple cycle. Given $$$n$$$, find the number of cyclic permutations of length $$$n$$$. Since the number may be very large, output it modulo $$$10^9+7$$$.Please refer to the Notes section for the formal definition of a simple cycle

The first and only line contains a single integer $$$n$$$ ($$$3 \le n \le 10^6$$$).

Output a single integer $$$0 \leq x < 10^9+7$$$, the number of cyclic permutations of length $$$n$$$ modulo $$$10^9+7$$$.

NoteThere are $$$16$$$ cyclic permutations for $$$n = 4$$$. $$$[4,2,1,3]$$$ is one such permutation, having a cycle of length four: $$$4 \rightarrow 3 \rightarrow 2 \rightarrow 1 \rightarrow 4$$$.Nodes $$$v_1$$$, $$$v_2$$$, $$$\ldots$$$, $$$v_k$$$ form a simple cycle if the following conditions hold:   $$$k \geq 3$$$.  $$$v_i \neq v_j$$$ for any pair of indices $$$i$$$ and $$$j$$$. ($$$1 \leq i < j \leq k$$$)  $$$v_i$$$ and $$$v_{i+1}$$$ share an edge for all $$$i$$$ ($$$1 \leq i < k$$$), and $$$v_1$$$ and $$$v_k$$$ share an edge.

import java.math.BigInteger

tailrec fun fac(n: BigInteger, acc: BigInteger): BigInteger =
    if (n == BigInteger.ONE) acc else fac(
        n - BigInteger.ONE,
        acc * n % BigInteger.valueOf(1000000007)
    )

fun pow(a: Int):Long{
    var n = a
    var base = 2L
    var num = 1L
    while (n> 0){
        if (n% 2== 1){
            num = num* base%1000000007L
        }
        n /= 2
        base = base*base%1000000007L
    }
    return num
}
fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    //val len = r.readLine()!!.toInt()
    //val (n, m, k) = r.readLine()!!.split(" ").map { it.toInt() }
    val n = r.readLine()!!.toLong()
    var ans = fac(BigInteger.valueOf(n), BigInteger.ONE) - pow((n-1).toInt()).toBigInteger()
    if (ans< BigInteger.ZERO) ans += BigInteger.valueOf(1000000007)
    println(ans)
}

import javafx.scene.layout.Priority
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.*
import kotlin.system.exitProcess

@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

const val _BUFFER_SIZE = 1 shl 16
@JvmField val _buffer = ByteArray(_BUFFER_SIZE)
@JvmField var _bufferPt = 0
@JvmField var _bytesRead = 0

tailrec fun readChar(): Char {
    if(_bufferPt == _bytesRead) {
        _bufferPt = 0
        _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)
    }
    return if(_bytesRead < 0) Char.MIN_VALUE
    else {
        val c = _buffer[_bufferPt++].toChar()
        if (c == '\r') readChar()
        else c
    }
}

fun readLine(): String? {
    var c = readChar()
    return if(c == Char.MIN_VALUE) null
    else buildString {
        while(true) {
            when(c) {
                '\n', Char.MIN_VALUE -> return@buildString
                else -> {
                    append(c)
                    c = readChar()
                }
            }
        }
    }
}
fun readLn() = readLine()!!

fun read() = buildString {
    var c = readChar()
    while(c <= ' ') {
        if(c == Char.MIN_VALUE) return@buildString
        c = readChar()
    }
    do {
        append(c)
        c = readChar()
    } while(c > ' ')
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

fun main() {
    val MOD = 1_000_000_000 + 7
    val n = readInt()

    var result = 1L

    for (i in 1..n) {
        result = result * i % MOD
    }

    var x = 1L
    for (i in 1..n-1) {
        x = (2 * x) % MOD
    }

    result = (result - x) % MOD
    if (result < 0) {
        result += MOD
    }

    println(result)
}

fun main() {
    val n = readInt()

    val mod = 1000000007L
    val factorial = (1L..n).reduce { acc, num -> (acc * num) % mod }
    val pow2 = (1 until n).fold(1L) { acc, _ -> (acc * 2) % mod }

    println(((factorial + mod) - pow2) % mod)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readInt() = readLn().toInt()

@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE")
//@file:OptIn(ExperimentalStdlibApi::class)

import java.io.File
import java.io.PrintWriter
import kotlin.math.*
import kotlin.random.Random
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln

/** @author Spheniscine */
fun main() { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
//    val startTime = System.nanoTime()

    val numCases = 1//readInt()
    case@ for(case in 1..numCases) {
//        print("Case #$case: ")

        val n = readInt()

        val ans = (1..n).productByModInt { ModInt(it) } - ModInt(2).pow(n-1)

        println(ans)
    }

//    iprintln("Time: ${(System.nanoTime() - startTime) / 1000000} ms")
}

const val BILLION7 = 1e9.toInt() + 7
const val MOD = BILLION7
const val TOTIENT = MOD - 1 // assumes MOD is prime

infix fun Int.modulo(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }
infix fun Long.modulo(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }
infix fun Long.modulo(mod: Int) = modulo(mod.toLong()).toInt()

fun Int.mulMod(other: Int, mod: Int) = toLong() * other modulo mod

fun Int.powMod(exponent: Long, mod: Int): Int {
    if(exponent < 0) error("Inverse not implemented")
    var res = 1L
    var e = exponent
    var b = modulo(mod).toLong()

    while(e > 0) {
        if(e and 1 == 1L) {
            res = res * b % mod
        }
        e = e shr 1
        b = b * b % mod
    }
    return res.toInt()
}
fun Int.powMod(exponent: Int, mod: Int) = powMod(exponent.toLong(), mod)
fun Int.modPowArray(n: Int, mod: Int): IntArray {
    val res = IntArray(n+1)
    res[0] = 1
    for(i in 1..n) res[i] = mulMod(res[i-1], mod)
    return res
}

inline fun Int.toModInt() = ModInt(this modulo MOD)
inline fun Long.toModInt() = ModInt(this modulo MOD)

/** note: Only use constructor for int within modulo range, otherwise use toModInt **/
inline class ModInt(val int: Int) {
    companion object {
        /** can't seem to make these private or inlined without causing compiler issues */
        @JvmField val _invMemo = HashMap<ModInt, ModInt>()
        fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }
    }

    // normalizes an integer that's within range [-MOD, MOD) without branching
    private inline fun normalize(int: Int) = ModInt((int shr Int.SIZE_BITS - 1 and MOD) + int)

    operator fun plus(other: ModInt) = normalize(int + other.int - MOD) // overflow-safe even if MOD >= 2^30
    inline operator fun plus(other: Int) = plus(other.toModInt())
    operator fun inc() = normalize(int + (1 - MOD))

    operator fun minus(other: ModInt) = normalize(int - other.int)
    inline operator fun minus(other: Int) = minus(other.toModInt())
    operator fun dec() = normalize(int - 1)
    operator fun unaryMinus() = normalize(-int)

    operator fun times(other: ModInt) = ModInt((int.toLong() * other.int % MOD).toInt())
    inline operator fun times(other: Int) = ModInt(int.mulMod(other, MOD))

    fun pow(exponent: Int): ModInt {
        val e = if(exponent < 0) {
            require(int != 0) { "Can't invert/divide by 0" }
            exponent modulo TOTIENT
        } else exponent
        return ModInt(int.powMod(e, MOD))
    }

    fun pow(exponent: Long) = if(int == 0) when {
        exponent > 0 -> this
        exponent == 0L -> ModInt(1)
        else -> error("Can't invert/divide by 0")
    } else pow(exponent modulo TOTIENT)

    inline fun inverse() = inv_memoized() /** NOTE: Change if necessary */

    fun inv_unmemoized(): ModInt {
        require(int != 0) { "Can't invert/divide by 0" }
        return pow(TOTIENT - 1)
    }
    inline fun inv_memoized() = _invMemoized(this)

    operator fun div(other: ModInt) = times(other.inverse())
    inline operator fun div(other: Int) = div(other.toModInt())

    override inline fun toString() = int.toString()
}

inline operator fun Int.plus(modInt: ModInt) = modInt + this
inline operator fun Int.minus(modInt: ModInt) = toModInt() - modInt
inline operator fun Int.times(modInt: ModInt) = modInt * this
inline operator fun Int.div(modInt: ModInt) = modInt.inverse() * this

inline class ModIntArray(val intArray: IntArray): Collection<ModInt> {
    inline operator fun get(i: Int) = ModInt(intArray[i])
    inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }

    override inline val size: Int get() = intArray.size
    inline val lastIndex get() = intArray.lastIndex
    inline val indices get() = intArray.indices

    override inline fun contains(element: ModInt): Boolean = element.int in intArray

    override fun containsAll(elements: Collection<ModInt>): Boolean = elements.all(::contains)

    override inline fun isEmpty(): Boolean = intArray.isEmpty()

    override fun iterator(): Iterator<ModInt> = object: Iterator<ModInt> {
        var index = 0
        override fun hasNext(): Boolean = index < size
        override fun next(): ModInt = get(index++)
    }

    fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))
    fun copyOf() = copyOf(size)
}
fun ModIntArray.copyInto(destination: ModIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =
    ModIntArray(intArray.copyInto(destination.intArray, destinationOffset, startIndex, endIndex))
inline fun ModIntArray(size: Int) = ModIntArray(IntArray(size))
inline fun ModIntArray(size: Int, init: (Int) -> ModInt) = ModIntArray(IntArray(size) { init(it).int })

fun ModInt.powArray(n: Int) = ModIntArray(int.modPowArray(n, MOD))

inline fun ModIntArray.first() = get(0)
inline fun ModIntArray.last() = get(lastIndex)
inline fun ModIntArray.joinToString(separator: CharSequence) = intArray.joinToString(separator)
inline fun <R> ModIntArray.fold(init: R, op: (acc: R, ModInt) -> R) = intArray.fold(init) { acc, i -> op(acc, ModInt(i)) }
inline fun <R> ModIntArray.foldRight(init: R, op: (ModInt, acc: R) -> R) = intArray.foldRight(init) { i, acc -> op(ModInt(i), acc) }
fun ModIntArray.sum() = fold(ModInt(0), ModInt::plus)
fun ModIntArray.product() = fold(ModInt(1), ModInt::times)

inline fun <T> Iterable<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Iterable<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
inline fun <T> Sequence<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Sequence<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
inline fun <T> Array<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Array<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
fun Iterable<ModInt>.sum() = sumByModInt { it }
fun Sequence<ModInt>.sum() = sumByModInt { it }
fun Iterable<ModInt>.product() = productByModInt { it }
fun Sequence<ModInt>.product() = productByModInt { it }
fun Collection<ModInt>.toModIntArray() = ModIntArray(size).also { var i = 0; for(e in this) { it[i++] = e } }

/** IO */
//@JvmField val INPUT = File("input.txt").inputStream()
//@JvmField val OUTPUT = File("output.txt").outputStream()
@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

const val _BUFFER_SIZE = 1 shl 16
@JvmField val _buffer = ByteArray(_BUFFER_SIZE)
@JvmField var _bufferPt = 0
@JvmField var _bytesRead = 0

tailrec fun readChar(): Char {
    if(_bufferPt == _bytesRead) {
        _bufferPt = 0
        _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)
    }
    return if(_bytesRead < 0) Char.MIN_VALUE
    else {
        val c = _buffer[_bufferPt++].toChar()
        if (c == '\r') readChar()
        else c
    }
}

fun readLine(): String? {
    var c = readChar()
    return if(c == Char.MIN_VALUE) null
    else buildString {
        while(c != '\n' && c != Char.MIN_VALUE) {
            append(c)
            c = readChar()
        }
    }
}
fun readLn() = readLine()!!

fun read() = buildString {
    var c = readChar()
    while(c <= ' ') {
        if(c == Char.MIN_VALUE) return@buildString
        c = readChar()
    }
    do {
        append(c)
        c = readChar()
    } while(c > ' ')
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

@JvmField val _writer = PrintWriter(OUTPUT, false)

/** shuffles and sort overrides to avoid quicksort attacks */
private inline fun <T> _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {
    // Fisher-Yates shuffle algorithm
    for (i in size - 1 downTo 1) {
        val j = rnd.nextInt(i + 1)
        val temp = get(i)
        set(i, get(j))
        set(j, temp)
    }
}

@JvmField var _random: Random? = null
val random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }

fun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun IntArray.sort() { shuffle(); _sort() }
fun IntArray.sortDescending() { shuffle(); _sortDescending() }

fun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun LongArray.sort() { shuffle(); _sort() }
fun LongArray.sortDescending() { shuffle(); _sortDescending() }

fun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun DoubleArray.sort() { shuffle(); _sort() }
fun DoubleArray.sortDescending() { shuffle(); _sortDescending() }

fun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T: Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T: Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T: Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T: Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()

fun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }

/** additional commons */
inline fun <T> Iterable<T>.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }
inline fun <T> Sequence<T>.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }
inline fun <T> Array<T>.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }
fun IntArray.sumLong() = fold(0L, Long::plus)

import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

// ModInt
// region
class ModInt(x: Long) {

    companion object {
        const val MOD = 1000000007L
        //const val MOD = 998244353L
    }

    val x = (x % MOD + MOD) % MOD

    operator fun plus(other: ModInt): ModInt {
        return ModInt(x + other.x)
    }

    operator fun minus(other: ModInt): ModInt {
        return ModInt(x - other.x)
    }

    operator fun times(other: ModInt): ModInt {
        return ModInt(x * other.x)
    }

    operator fun div(other: ModInt): ModInt {
        return this * other.inv()
    }

    fun pow(exp: Long): ModInt {
        if (exp == 0L) return ModInt(1L)
        var a = pow(exp shr 1)
        a *= a
        if (exp and 1L == 0L) return a
        return this * a
    }

    fun inv(): ModInt {
        return this.pow(MOD - 2)
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as ModInt

        if (x != other.x) return false

        return true
    }

    override fun hashCode(): Int {
        return x.hashCode()
    }

    override fun toString(): String {
        return "$x"
    }

}

val fac = mutableListOf<ModInt>()
val invfac = mutableListOf<ModInt>()

fun fact(n: Long, b: Boolean): ModInt {
    if (fac.count() == 0) {
        fac.add(ModInt(1))
        invfac.add(ModInt(1))
    }
    while (fac.count() <= n) {
        fac.add(fac.last() * ModInt(fac.count().toLong()))
        invfac.add(fac.last().inv())
    }
    return if (b) {
        fac[n.toInt()]
    } else {
        invfac[n.toInt()]
    }
}

fun comb(n: Long, k: Long): ModInt {
    return fact(n, true) * fact(k, false) * fact(n - k, false)
}

fun comb2(n: Long, k: Long): ModInt {
    var ans = ModInt(1)
    for (i in 0 until k) {
        ans = ans * ModInt(n - i) / ModInt(k - i)
    }
    return ans
}
// endregion

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextLong()
    var fac = ModInt(1)
    for (i in 1..n) {
        fac *= ModInt(i)
    }
    println(fac - ModInt(2).pow(n - 1))
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

fun main() {
    val mod = 1000000007
    val n = readLine()!!.toLong()
    var yes = 0L
    var no = 2L
    for (i in 3..n) {
        yes = (i * yes + (i - 2) * no) % mod
        no = (2 * no) % mod
    }
    println(yes)
}

import java.util.*
const val MOD=1000000007
const val MODL=1000000007L

fun main() {
    val n = readInt()
    var ans = 1L
    for (i in 2..n) ans=(ans*i)%MODL
    ans=(ans-mp(2L,(n-1).toLong())+MODL)%MODL
    println(ans)
}

fun gcd (a: Int,b: Int): Int = if (b==0) a else gcd(b,a%b)
fun mp (a: Long,p: Long): Long {
    var ret=1L
    var pow=p
    var x=a
    while (pow>0) {
        if ((pow and 1)>0) ret=(ret*x)%MODL
        pow=pow.shr(1)
        x=(x*x)%MODL
    }
    return ret
}
fun YN(b: Boolean) : String { return if (b) "YES" else "NO"  }
fun readLn() = readLine()!! // string line
fun readInt() = readLn().toInt() // single int
fun readLong() = readLn().toLong()
fun readStrings() = readLn().split(" ") // list of strings
fun readInts() = readStrings().map { it.toInt() } // list of ints
fun readLongs() = readStrings().map { it.toLong() } // list of longs
fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun modFactorial (n: Long, mod: Long) : Long {
    var result = 1L
    for (i in 1..n) result = (result * i) % mod
    return result
}

fun modExp (base: Long, exp: Long, mod: Long) : Long {
    var b = base
    var e = exp
    var result = 1L
    while (e > 0) {
        if (e % 2L == 0L) {
            b = (b * b) % mod
            e /= 2L
        } else {
            result = (result * b) % mod
            e--
        }
    }
    return result
}

fun cyclePermutations (n : Long, mod : Long) : Long {
    val r = modFactorial(n, mod) - modExp(2, n - 1, mod)
    return (r + mod) % mod
}

fun main() {
    val p = 1000000007L
    val n = readLine()!!.toLong()
    println(cyclePermutations(n, p))
}

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

const val MOD: Int = 1_000_000_000 + 7

inline class IntMod(private val i: Int) {
    operator fun plus(increment: IntMod): IntMod = IntMod(Math.floorMod(i + increment.i, MOD))
    operator fun plus(increment: Int): IntMod = this + increment.moduloArithmetic()

    operator fun minus(other: IntMod): IntMod = IntMod(Math.floorMod(i - other.i, MOD))
    operator fun minus(decrement: Int): IntMod = this - decrement.moduloArithmetic()

    operator fun times(other: IntMod): IntMod = IntMod(Math.floorMod(i.toLong() * other.i, MOD.toLong()).toInt())
    operator fun times(other: Int): IntMod = this * other.moduloArithmetic()

    operator fun div(other: IntMod): IntMod = this * other.multiplicativeInverse()
    operator fun div(other: Int): IntMod = this / other.moduloArithmetic()

    override fun toString(): String = i.toString()

    private fun multiplicativeInverse(): IntMod = pow(MOD-2)

    // i^n
    fun pow(n_in: Int): IntMod {
        var x = this
        var y = IntMod(1)
        var n = n_in
        // x^n
        while (n > 0) {
            if (n % 2L != 0L) y *= x
            n /= 2
            x *= x
        }
        return y
    }

}

fun Int.moduloArithmetic() : IntMod = IntMod(this % MOD)

fun Int.factorialModulo(): IntMod {
    var res = 1.moduloArithmetic()
    for (i in 2..this) {
        res *= i
    }
    return res
}

fun main() {
    val n = readInt()

    // Compute:  n! - sum_i{1,n} choose(i-1, n-1)
    //        =  n! - 2^{n-1}

    val fact = n.factorialModulo()
    val pow = 2.moduloArithmetic().pow(n-1)

    println(fact - pow)
}

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

const val MOD: Int = 1_000_000_000 + 7

inline class IntMod(private val i: Int) {
    operator fun plus(increment: IntMod): IntMod = IntMod(Math.floorMod(i + increment.i, MOD))

    operator fun minus(other: IntMod): IntMod = IntMod(Math.floorMod(i - other.i, MOD))

    operator fun times(other: IntMod): IntMod = IntMod(Math.floorMod(i.toLong() * other.i, MOD.toLong()).toInt())
    operator fun times(other: Int): IntMod = this * other.moduloArithmetic()

    override fun toString(): String = i.toString()
}

fun Int.moduloArithmetic() : IntMod = IntMod(this % MOD)

fun main() {
    val n = readInt()

    // Compute:  n! - sum_i{1,n} choose(i-1, n-1)
    //        =  n! - 2^{n-1}

    var fact = 1.moduloArithmetic()
    var pow = 1.moduloArithmetic()
    for (i in 1 until n) {
        fact *= i+1
        pow *= 2
    }

    println(fact - pow)
}

import java.util.*

private inline fun debug(str: () -> Any?) = println(str().toString()) //{}
private inline fun readInt() = reader.nextInt()
private inline fun readLong() = reader.nextLong()
private inline fun readDouble() = reader.nextDouble()
private inline fun readArr() = readLine()!!.split(" ").map { it.toInt() }
private inline fun readArr(n: Int) = List<Int>(n) { reader.nextInt() }
private inline fun readArrLong() = readLine()!!.split(" ").map { it.toLong() }
private inline fun readArrLong(n: Int) = List<Long>(n) { reader.nextLong() }
private inline fun readArrDouble() = readLine()!!.split(" ").map { it.toDouble() }
private inline fun readArrDouble(n: Int) = List<Double>(n) { reader.nextDouble() }
private inline fun readLineAsCharList() = reader.nextLine().asSequence().toList()
private inline fun readAndSolve(f: () -> Unit): Unit {
    val n = readInt()
    // usually n is the only value in string
    reader.nextLine()
    repeat(n) { f() }
}

private fun Boolean.yn() = if (this) "YES" else "NO"
private fun <T> Iterable<T>.out() = this.joinToString(" ")
private val reader = Scanner(System.`in`.bufferedReader()).apply { useLocale(Locale.US) }

@ExperimentalStdlibApi
fun main() = solve1391C()

@ExperimentalStdlibApi
private fun solve1391C() {

    val n = readInt()

    val mod = 1000_000_007L

    // ans = n! - 2^(n-1)

    var fact = 1L
    for (i in 2..n)
        fact = (fact * i) % mod

    var powtwo = 2L
    for (i in 3..n)
        powtwo = (powtwo * 2) % mod

    val ans = (fact + (mod - powtwo) % mod ) % mod

    println(ans)

}

import java.io.*
import java.util.*
import kotlin.math.*

fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))

	val n = f.readLine().toInt()

	val MOD : Long = 1000000007L

	val fac = LongArray(1000005){0L}
	val pow2 = LongArray(1000005){0L}
	fac[0] = 1L
	pow2[0] = 1L

	for(k in 1 until 1000005){
		fac[k] = (k.toLong()*fac[k-1] + MOD)%MOD
		pow2[k] = (2L*pow2[k-1] + MOD)%MOD
	}

	val answer = ((fac[n]-pow2[n-1] + MOD)%MOD+MOD)%MOD
	println(answer)
}

const val MOD = 1000000007L

fun main() {
    val n = readLine()!!.toInt()
    var answer = 1L
    for (j in 1L..n.toLong()) {
        answer *= j
        answer %= MOD
    }
    var subtractend = 1L
    for (j in 2..n) {
        subtractend *= 2L
        subtractend %= MOD
    }
    answer -= subtractend
    answer %= MOD
    answer += MOD
    answer %= MOD
    println(answer)
}

import java.util.Queue
import java.util.LinkedList
import kotlin.collections.*
import kotlin.math.*
import java.util.Scanner
import java.lang.Math.floorMod
import java.lang.Math.floorDiv
import java.io.File
import kotlin.comparisons.compareBy

fun readLn() = readLine()!!.trim() // string line
fun readInt() = readLn().trim().toInt() // single int
fun readStrings() = readLn().trim().split(" ") // list of strings
fun readInts() = readStrings().map { it.trim().toInt() } // list of ints
fun readLongs() = readStrings().map { it.trim().toLong() } // list of ints
fun readLong() = readLn().trim().toLong() // list of strings
fun writeGoogleAnswer(case: Int, str: String) = println("Case #$case: $str")

data class Point(val x: Long, val y: Long)

fun main(args: Array<String>) {
    val mod = 1000000007L
    val n = readLong()
    var prevCnt = 4L
    var fact = 6L
    for (i in 4..n) {

        prevCnt = (2L*prevCnt) % mod
        fact = (fact*i) % mod
    }

    println(floorMod(fact - prevCnt, mod))

}

import java.io.*
import java.util.*
import kotlin.math.*

fun min(a: Int, b: Int): Int {
    if (a < b) {
        return a
    } else {
        return b
    }
}

fun max(a: Int, b: Int): Int {
    if (a > b) {
        return a
    } else {
        return b
    }
}

fun main(args:Array<String>) {
    val reader = BufferedReader(InputStreamReader(System.`in`))
    val writer = BufferedWriter(OutputStreamWriter(System.out))

    val n = reader.readLine().toLong()
    val mn: Long = 1000000000 + 7

    var ans: Long = 1
    var minus: Long = 1
    for (i in 1..n-1) {
	ans *= i
	ans %= mn

	if (i.toInt() != 1) {
	    minus *= 2
	    minus %= mn
	}
    }

    ans = (n*ans - minus*2) % mn

    writer.write("$ans\n")

    writer.flush()
    reader.close()
    writer.close()
}

/* template start */
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*

private val br = BufferedReader(InputStreamReader(System.`in`))
private var st = StringTokenizer("")

private fun readString(): String {
    while (!st.hasMoreTokens()) try {
        st = StringTokenizer(br.readLine())
    } catch (e: IOException) {
        e.printStackTrace()
    }
    return st.nextToken()
}

private fun readInt(): Int = readString().toInt()
private fun readLong(): Long = readString().toLong()
private fun readDouble(): Double = readString().toDouble()
private fun readArray(n: Int) = IntArray(n) { readInt() }
private fun readLongArray(n: Int) = LongArray(n) { readLong() }
private fun readDoubleArray(n: Int) = DoubleArray(n) { readDouble() }

private fun queries(block: (Int) -> Unit) = repeat(readInt(), block)

/* template end */

private val MOD = (1e9 + 7).toInt()

fun main() {
    val n = readInt()
    var ans = 1L
    for (i in 2..n) {
        ans = (ans * i) % MOD
    }
    var pow = 1L
    for (i in 1..n-1)
        pow = (pow * 2L) % MOD

    println((ans - pow + MOD) % MOD)
}

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

const val MOD: Int = 1_000_000_000 + 7

inline class IntMod(private val i: Int) {
    operator fun plus(increment: IntMod): IntMod = IntMod(Math.floorMod(i + increment.i, MOD))

    operator fun minus(other: IntMod): IntMod = IntMod(Math.floorMod(i - other.i, MOD))

    operator fun times(other: IntMod): IntMod = IntMod(Math.floorMod(i.toLong() * other.i, MOD.toLong()).toInt())
    operator fun times(other: Int): IntMod = this * other.moduloArithmetic()

    override fun toString(): String = i.toString()
}

fun Int.moduloArithmetic() : IntMod = IntMod(this % MOD)

fun main() {
    val n = readInt()

    // Compute:  n! - sum_i{1,n} choose(i-1, n-1)
    //        =  n! - 2^{n-1}

    var fact = 1.moduloArithmetic()
    var pow = 2.moduloArithmetic()
    for (i in 1 until n) {
        fact *= i+1
        pow *= 2
    }

    println(fact - pow)
}

import java.io.*
import java.util.*
import kotlin.math.*

fun min(a: Int, b: Int): Int {
    if (a < b) {
        return a
    } else {
        return b
    }
}

fun max(a: Int, b: Int): Int {
    if (a > b) {
        return a
    } else {
        return b
    }
}

fun main(args:Array<String>) {
    val reader = BufferedReader(InputStreamReader(System.`in`))
    val writer = BufferedWriter(OutputStreamWriter(System.out))

    val n = reader.readLine().toLong()
    val mn: Long = 1000000000 + 7

    var ans: Long = 1
    var minus: Long = 1
    for (i in 1..n) {
	ans *= i
	ans %= mn
	if (i.toInt() != 1) {
	    minus *= 2
	    minus %= mn
	}
    }

    ans -= minus

    writer.write("$ans\n")

    writer.flush()
    reader.close()
    writer.close()
}


There are n stones on the table in a row, each of them can be red, green or blue. Count the minimum number of stones to take from the table so that any two neighboring stones had different colors. Stones in a row are considered neighboring if there are no other stones between them.

The first line contains integer n (1 ≤ n ≤ 50) — the number of stones on the table.  The next line contains string s, which represents the colors of the stones. We'll consider the stones in the row numbered from 1 to n from left to right. Then the i-th character s equals "R", if the i-th stone is red, "G", if it's green and "B", if it's blue.

Print a single integer — the answer to the problem.

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)
    }

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 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))
}