jiahuimbzuai/CoQuIR huggingface dataset:
//  [go]
package main

import (
  "fmt"
  "math"
)

func main() {
  var n float64
  fmt.Scan(&n)
  fmt.Println(int(math.Pow(math.Floor(math.Sqrt(n)), 2)))
}
//  [go]
package main

import (
	"fmt"
	"math"
)

func isInt(n float64) bool {
	return math.Floor(n) == n
}

func main() {
	var n float64
	fmt.Scan(&n)

	for i := n; 0 < i; i-- {
		n := math.Sqrt(i)
		if isInt(n) {
			fmt.Println(int(i))
			break
		}
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanInit()

	n := nextInt()

	maxs := 0
	for i := 1; i*i < n; i++ {
		maxs = i * i
	}

	fmt.Println(maxs)

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	for i := n; i > 0; i-- {
		for j := 1; j < 100000; j++ {
			if j*j == i {
				fmt.Println(i)
				return
			}
		}
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readFloat64() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func main() {
	n := readFloat64()
	v := math.Floor(math.Sqrt(n))
	fmt.Println(v * v)
}
//  [ruby]
n=gets.to_i
m=Math.sqrt(n).round
a=0
i=m+10
while i>=0
   j=i**2
   if j<=n
       a=j
       break
    end
   i-=1
end
puts a
//  [ruby]
n = gets.to_i
puts (Math.sqrt(n).to_i)**2
//  [ruby]
puts Math.sqrt(gets.to_i).floor ** 2
//  [ruby]
n=gets.to_i
(1..Integer.sqrt(n)+1).reverse_each do |i|
  if i**2==n
    p i**2
    break
  end
end
//  [ruby]
n=gets.to_i
m=Math.sqrt(n).floor(0)
a=0
i=m+10
while i>=0
   j=i**2
   if j<=n
       a=j
       break
    end
   i-=1
end
puts a
//  [ruby]
n=gets.to_i
a=[]
for i in 0..n
    v=i**2
    if v<=n
    a<<i
    end
end
puts a.max
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize
    }
    let mut i = 0;
    while (i + 1) * (i + 1) <= n {
        i += 1;
    }
    println!("{}", i * i);
}
//  [rust]
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let n: u64 = input();
    let mut i = 1;
    while i*i <= n {        
        i += 1;
    }
    println!("{}", (i-1)*(i-1));
}
//  [rust]
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize
    };
    let num = (1..).find(|i| i * i > n).unwrap() - 1;
    println!("{}", num * num);
}
//  [rust]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut ans: usize = 1;

    while ans * ans < n {
        ans += 1;
    }
    println!("{}", (ans - 1) * (ans - 1));
}
//  [swift]
import Foundation

let n = Int(readLine()!)!
var ans = 1
for i in (1...n).reversed() {
  if sqrt(Double(i)) == floor(sqrt(Double(i))) {
    ans = i
    break
  }
}
print(ans)
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//var min, min2, count: Int!
//for i in 1...10 {
//    let x = Int(readLine()!)!
//    if i == 1 {
//        min = x
//        count = 1
//    } else if x < min {
//        min2 = min
//        min = x
//        count = 1
//    } else if x == min && count == 1 {
//        min2 = x
//        count = 2
//    }
//}
//print(min2)

/*************** メインプログラム ***************/

let N = readInt()!
var ans = 1
for i in 1...31622 {
    let square = i * i
    if square > N {
        break
    } else {
        ans = square
    }
}
print(ans)
//  [swift]
//
//  main.swift
//  AtCoderSwift
//
//  Created by burita083 on 2020/08/25.
//  Copyright © 2020 burita083. All rights reserved.
//

import Foundation
func readInt() -> Int {
    return Int(readLine()!)!
}
 
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
 
func readTwoInts() -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: " ").map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

func abc080_b() {
    let N = readLine()!
    let sum = N.map { Int(String($0))! }.reduce(0, +)
    print(Int(N)! % sum == 0 ? "Yes" : "No")
}

//abc080_b()

func abc078_b() {
    let input = readInts()
    var X = input[0]
    let Y = input[1]
    let Z = input[2]
    var ans = 0
    X -= Y+Z*2
    ans += 1
    ans += X/(Y+Z)
    
    print(ans)
}

func abc085_b() {
    let N = readInt()
    var l: [Int] = []
    for _ in 0..<N {
        let d = readInt()
        l.append(d)
    }
    print(l.reduce([], { $0.contains($1) ? $0 : $0 + [$1] }).count)
}

func isSquare(n: Double) -> Bool {
    let sqrt = floor(n.squareRoot())
    return sqrt * sqrt == n
}

func abc077_b() {
    let N = readInt()
    for n in (1...N).reversed() {
        if isSquare(n: Double(n)) {
            print(n)
            return
        }
    }
}

abc077_b()
//  [swift]
//
//  main.swift
//  AtCoderSwift
//
//  Created by burita083 on 2020/08/25.
//  Copyright © 2020 burita083. All rights reserved.
//

import Foundation
func readInt() -> Int {
    return Int(readLine()!)!
}
 
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
 
func readTwoInts() -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: " ").map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

func abc080_b() {
    let N = readLine()!
    let sum = N.map { Int(String($0))! }.reduce(0, +)
    print(Int(N)! % sum == 0 ? "Yes" : "No")
}

//abc080_b()

func abc078_b() {
    let input = readInts()
    var X = input[0]
    let Y = input[1]
    let Z = input[2]
    var ans = 0
    X -= Y+Z*2
    ans += 1
    ans += X/(Y+Z)
    
    print(ans)
}

func abc085_b() {
    let N = readInt()
    var l: [Int] = []
    for _ in 0..<N {
        let d = readInt()
        l.append(d)
    }
    print(l.reduce([], { $0.contains($1) ? $0 : $0 + [$1] }).count)
}

func isSquare(n: Double) -> Bool {
    let sqrt = n.squareRoot()
    return sqrt * sqrt == n
}

func abc077_b() {
    let N = readInt()
    for n in (1...N).reversed() {
        print(n)
        if isSquare(n: Double(n)) {
            return
        }
    }
}

abc077_b()
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//var min, min2, count: Int!
//for i in 1...10 {
//    let x = Int(readLine()!)!
//    if i == 1 {
//        min = x
//        count = 1
//    } else if x < min {
//        min2 = min
//        min = x
//        count = 1
//    } else if x == min && count == 1 {
//        min2 = x
//        count = 2
//    }
//}
//print(min2)

/*************** メインプログラム ***************/

let N = readInt()!
for i in 1...31622 {
    let square = i * i
    if square > N {
        print(square)
        break
    }
}
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const gojo=(a:number,b:number):number=>{if(a%b===0)return b;return gojo(b,a%b)};
const main=()=>{
  let n=tn()
  for(let i=n;i>0;i--){
    if(Number.isInteger(Math.sqrt(i))){
      to(i)
      return
    }
  }
}
main()
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = Number(stdin.split('\n')[0])

const ans = _ => {
  for (let i = n; i > 0; i--) {
    const root = Math.sqrt(i)
    if (Number.isInteger(root)) {
      return i
    }
  }
}

console.log(ans())
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);

  let answer = 0;

  for (let i = 1; i; i++) {
    const squareNumber = i * i;

    if (squareNumber > N) {
      break;
    }

    answer = squareNumber;
  }

  return answer;
};

console.log(main(read()));
//  [typescript]
// const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const stdin = `271828182`

const n = Number(stdin.split('\n')[0])

const ans = _ => {
  for (let i = n; i > 0; i--) {
    const root = Math.sqrt(i)
    if (Number.isInteger(root)) {
      return i
    }
  }
}

console.log(ans())
//  [python]
a, b, h = (int(input()) for u in range(3))
print(int((a + b) * h / 2))
//  [python]
a = int(input())
b = int(input())
h = int(input())

print(int((a + b)*h/2))
//  [python]
a = int(input())
b = int(input())
h = int(input())
print(int(((a + b) * h) / 2))
//  [python]
a = int(input())
b = int(input())
h = int(input())

print((a + b) * h / 2)
//  [python]
a, b, h = map(int, input().split())
print((a + b) * h // 2)
//  [python]
a,b,h = map(int,input().split())

print(((a+b)*h)//2)
//  [java]
import java.io.*;
public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader reader= new BufferedReader(new InputStreamReader(System.in));
    int a = Integer.parseInt(reader.readLine());
    int b = Integer.parseInt(reader.readLine());
    int h = Integer.parseInt(reader.readLine());
    System.out.println((a+b)*h/2);}}
//  [java]
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int ans = (a + b) * h / 2;
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}
//  [java]
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        System.out.println(((fsc.nextInt()+fsc.nextInt())*fsc.nextInt())/2);
        fsc.close();
        
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}
//  [java]
import java.util.*;
import java.io.*;

public class Main{
    
    

     public static void main(String []args){
       Scanner scanner = new Scanner(System.in);
       String a = scanner.next();
       String b = scanner.next();
       String c = scanner.next();
       List<Character> list1 = new ArrayList<>();
       List<Character> list2= new ArrayList<>();
       List<Character> list3 = new ArrayList<>();
       
       int current =1;
       
       for(int i=0;i<a.length();i++)
       list1.add(a.charAt(i));
       
       for(int i=0;i<b.length();i++)
       list2.add(b.charAt(i));
       
       for(int i=0;i<c.length();i++)
       list3.add(c.charAt(i));
      
       outerloop:
       while(list1.size()!=0 || list2.size()!=0 || list3.size()!=0 )
       {
           
        
         
          if(current==1)
          {
              
              while(list1.size()!=0 &&list1.get(0)=='a' )
              {
                
                  list1.remove(0);
              }
              if(list1.size()!=0 && list1.get(0)=='b' )
              current =2;
               if( list1.size()!=0 && list1.get(0)=='c')
               current =3;
               
               if(list1.size()!=0)
              list1.remove(0);
              else break outerloop;
              
          }
          
          else if(current==2)
          {
              while(list2.size()!=0 && list2.get(0)=='b')
              {
                  list2.remove(0);
              }
              if(list2.size()!=0 && list2.get(0)=='a' )
              current =1;
               if(list2.size()!=0 && list2.get(0)=='c')
               current =3;
               
                if(list2.size()!=0)
                  list2.remove(0);
                else break outerloop;
              
          }
          
          else if(current==3)
          {
              while(list3.size()!=0 && list3.get(0)=='c' )
              {
                  list3.remove(0);
              }
              if(list3.size()!=0 &&list3.get(0)=='a')
              current =1;
               if(list3.size()!=0 && list3.get(0)=='b' )
               current =2;
               
                if(list3.size()!=0)
                  list3.remove(0);
                else break outerloop;
              
          }
       }
       
       if(list1.size()==0)
       System.out.println("A");
       else if(list2.size()==0)
       System.out.println("B");
       else if(list3.size()==0)
       System.out.println("C");
       
       
     }
}
//  [java]
import java.util.*;
// . >
class A{
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		
		int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
			
		System.out.println((a + b) * c / 2);
	}

}
//  [java]
import java.util.*;
// . >
public class A{
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		
		int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
			
		System.out.println((a + b) * c / 2);
	}

}
//  [cpp]
#include <stdio.h>
int main(){
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	d=((a+b)*c)/2;
	printf("%d",d);
	return 0;
}
//  [cpp]
#include <stdio.h>

int main(){
    int a,b,h;
    scanf("%d%d%d",&a,&b,&h);
    printf("%d\n",(a+b)*h/2);
}
//  [cpp]
#include<stdio.h>
#include<cmath>
int main(){
	int a,b,h;
	int area;
	scanf("%d\n%d\n%d",&a,&b,&h);
    area=(a+b)*h/2;
    printf("%d\n",area);
    return 0;
}
//  [cpp]
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
#define P pair<int,int>
#define F first
#define S second

using namespace std;

int main(){
  int a,b,h;
  cin >> a >> b >> h;
  cout << (a + b) * h / 2
}
//  [cpp]
#include <iostream>
using namespace std;

int main(){
  int a;
  cin >> a;
  int b:
  cin >> b;
  int h;
  cin >> h;
  cout << (a+b)*h/2;
}
//  [cpp]
#include <iostream>

using namespace std;

int main(){
 int a;
 cin >> a;
  int b;
 cin >> b;
  int h;
 cin >> h;
  cout << (a+b)*h/2
}
//  [c]
#include<stdio.h>
int main(void){
  int a,b,h,s;
  scanf("%d%d%d",&a,&b,&h);
  s=(a+b)*h/2;
  printf("%d",s);
  return 0;
}
//  [c]
#include<stdio.h>
int main()
{
    int a, b, h;
    scanf("%d%d%d", &a, &b, &h);
    printf("%d\n", (h/2)*(a+b));
    return 0;
}
//  [c]
#include<stdio.h>
int main()
{
    int a,b,h,ar,area;
    scanf("%d %d %d",&a,&b,&h);
    if(h%2==0)
    {
        ar = (a+b)*h;
        area = ar / 2;

        printf("%d",area);
    }
    return 0;

}
//  [c]
a,b,h=int(input.split())
print((a+b)*h/2)
//  [c]
#include <stdio.h>

int main(void)
{
  int a;
  int b;
  int h;

  scanf("%d\n",&a);
  scanf("%d\n",&b);
  scanf("%d\n",&h);

  printf("%d",(a+b) / 2 * h);
  return 0;
}
//  [c]
#include <stdio.h>

int main(void)
{
  int a;
  int b;
  int c;
  int ans;

  scanf("%d,%d,%d",&a,&b,&c);

  ans = (a+b) * c /2;
  printf("%d\n",ans);

  return 0;
}
//  [javascript]
'use strict';
function Main(input) {
  input = input.split("\n");
  var a = parseInt(input[0], 10);
  var b = parseInt(input[1], 10);
  var h = parseInt(input[2], 10);
  console.log(((a + b) * h) / 2);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  input = input.split("\n");
  const a = parseInt(input[0], 10);
  const b = parseInt(input[1], 10);
  const h = parseInt(input[2], 10);

  var S = ((a + b) * h) / 2.0;
  console.log(S);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  const tmp = input.trim().split('\n').map(v => parseInt(v, 10))

  const a = tmp[0];
  const b = tmp[1];
  const h = tmp[2];

  const result = ((a + b) * h) / 2;

  console.log(result);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
const sqare = (a,b,h) => {
  return ( a + b) * h / 2
}
//  [javascript]
const squaire = (a, b, c) => {
  (a + b) * 2 / 2
}
//  [javascript]
function num(a, b, h) {
  return ((a + b) * h) / 2;
}
console.log(num(2, 3, 5));
//  [go]
package main

import (
  "fmt"
)

func main() {
  var a, b, h int
  fmt.Scan(&a, &b, &h)
  fmt.Println((a + b) * h / 2)
}
//  [go]
package main

import(
	"fmt"
  	"bufio"
  	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() int{
  sc.Scan()
  i, _:= strconv.Atoi(sc.Text())
  return i
}

func main(){
  a,b,h := nextLine(),nextLine(),nextLine()
  var total = 0
  if a==b && b == h && a == h{
  	total = b*h
  }else{    
    total = (a + b)*h/h
  }
  fmt.Println(total)
}
//  [go]
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main(){
    
    a := nextInt()
    b := nextInt()
    h := nextInts(N)
    
	fmt.Println((a+b)*h/2)
}
 
/* templates */


func Max(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a float64) float64 {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    a, b int
}
 
type Pairs []Pair
 
func (p Pairs) Len() int {
    return len(p)
}
 
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
func (p Pairs) Less(i, j int) bool {
    return p[i].b < p[j].b
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}

func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}

func nextStrings(n int) []string {
    r := make([]string, n)
    for i := 0; i < n; i++ {
        r[i] = nextString()
    }
    return r
}

func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}
//  [go]
import "fmt"
 
func main() {
    var a, b, h int
    fmt.Scan(&a, &b, &h)
    fmt.Println((a + b) * h / 2)
}
//  [ruby]
puts (gets.to_i + gets.to_i) * gets.to_i / 2
//  [ruby]
a, b, n = readlines.map(&:to_i)
p (a + b) * n / 2
//  [ruby]
a = gets.to_i
b = gets.to_i
h = gets.to_i
puts (a+b)*h/2
//  [ruby]
a = gets.chomp
b = gets.chomp
c = gets.chomp
p (a+b)*c/2
//  [ruby]
w = gets + gets
s = w * gets / 2
puts s
//  [ruby]
a, b, h  = $stdin.read.split

def area (a,b,h)
    (a+b)*h/2
end

puts area(a,b,h)
//  [rust]
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let abh = io.readn::<i64>(3);

    io.writeln((abh[0] + abh[1]) * abh[2] / 2);
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a:usize,
        b:usize,
        h:usize
    }
    println!("{}", (a+b)*h/2);
}
//  [rust]
use std::collections::HashMap;
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let a: i64 = s.trim().parse().unwrap();
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let b: i64 = s.trim().parse().unwrap();
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let h: i64 = s.trim().parse().unwrap();

    println!("{}", (a + b) * h / 2);
}
//  [rust]
fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let h: u32 = read();
    let ans = (a+b) * h;
    println!("{}", ans);
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 1_000_000_007;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

pub fn factorial(n: u32) -> u32 {
    if n == 0 {
        return 1;
    }
    let mut r = n;
    for i in 0..n - 1 {
        r *= n - i - 1;
    }
    r
}

pub fn combination(n: u32, m: u32) -> u32 {
    factorial(n) / factorial(m) / factorial(n - m)
}
//  [rust]
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| i64::from_str(n).unwrap());
    let a = it.next().unwrap();

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| i64::from_str(n).unwrap());
    let b = it.next().unwrap();

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| i64::from_str(n).unwrap());
    let c = it.next().unwrap();


    println!("{}", (a + b) * c / 2);
}
//  [swift]
print((Int(readLine()!)!+Int(readLine()!)!)*Int(readLine()!)!/2)
//  [swift]
func i()->Int{return Int(readLine()!)!};print((i()+i())*i()/2)
//  [swift]
let a: Int = Int(readLine()!)!
let b: Int = Int(readLine()!)!
let h: Int = Int(readLine()!)!
 
print((a + b) * h / 2)
//  [swift]
import Foundation
 
let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")
 
let a = Int(split[0])!
let b = Int(split[1])!
let h = Int(split[2])!

print( (a + b) * h / 2)
//  [swift]
import Foundation
 
let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")
 
let a = Int(split[0])!
let b = Int(split[1])!
let h = Int(split[2])!

print((a+b)*h/2)
//  [swift]
import Foundation
 
let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")
 
let a = Int(split[0])!
let b = Int(split[1])!
let h = Int(split[2])!

print(((a+b)*h)/2)
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  out(floor((nin()+nin())*nin()/2))
}
main()
//  [typescript]
import * as fs from "fs";
 
let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
var a = parseInt(input[0]);
var b = parseInt(input[1]);
var h = parseInt(input[2]);
var result = (a + b) * h / 2;

console.log(result);
//  [typescript]
function main(input: string) {
  const [a, b, h] = input.split("\n").map((elm: string) => Number(elm));
  console.log(((a + b) * h) / 2);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
import * as fs from "fs";
const input = fs.readFileSync("/dev/stdin", "utf-8");

const main = (input: string): void => {
  const [a, b, c] = input.split("\n").map((str) => str.split(""));
  let next: string = "";

  const term = (str: string) => {
    console.log(str);
  };

  term(a[0]);
};

main(input);
//  [typescript]
import * as fs from "fs";
const input = fs.readFileSync("/dev/stdin", "utf-8");

const main = (input: string): void => {
  console.log("YES");
};

main(input);
//  [typescript]
import * as fs from "fs";
const input = fs.readFileSync("/dev/stdin", "utf-8");

const main = (input: string): void => {
  let [a, b, c] = input.split("\n").map((str) => str.split(""));
  let next: string = "";

  const term = (str: string) => {
    if (str === "a") next = a.shift() ?? "";
    else if (str === "b") next = b.shift() ?? "";
    else if (str === "c") next = c.shift() ?? "";

    if (next === "") console.log(str.toUpperCase());
    else term(next);
  };

  term(a[0]);
};

main(input);
//  [python]
# -*- coding: utf-8 -*-
n,k = list(map(int,input().split()))
s = input()
rl_cnt = s.count("RL")
ret = 0
s0 = s[0]
sn = s[-1]
if s0==sn:
    ret=n-1-2*max(0,rl_cnt-k)
elif s0=="L" and sn=="R":
    if k<=rl_cnt:
        ret=n-2-2*(rl_cnt-k)
    else:
        ret=n-1
else:
    if k<rl_cnt:
        ret = n - 2*(rl_cnt-k)
    else:
        ret = n-1
print(ret)
//  [python]
n, k = map(int, input().split())
s = input()
cnt = s.count('LR') + s.count('RL') + 1
ans = n - cnt + (2 * min(k, cnt))
print(min(n-1, ans))
//  [python]
N,K = map(int,input().split())
S = input()
happiness = N-1 - S.count('LR') - S.count('RL')
print(min(N-1,happiness+2*K))
//  [python]
n, k = [int(i) for i in input().split()]
s = list(input())
c, cnt = 0, 0
cnt = 0
if s[0] == 'L':
  cnt += 1
if s[-1] == 'R':
  cnt += 1
for i in range(n-1):
  if s[i] == 'R' and s[i+1] == 'L':
    c += 1
if c > 0:
  if c - k >= 0:
    c -= k
  else:
    c = 0
    cnt = 1
print(n - 2*c - cnt)
//  [python]
n, k = [int(i) for i in input().split()]
s = list(input())
c, r, l = 0, 0, 0
if s[0] == 'L':
  l = 1
if s[-1] == 'R':
  r = 1
for i in range(n-1):
  if s[i] == 'R' and s[i+1] == 'L':
    c += 1
if c - k >= 0:
  c -= k
else:
  c = 0
  r = 0
print(n - r - l - 2*c)
//  [python]
n,k=map(int,input().split())
s=input()

cnt=0
lst=[]
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        cnt+=1
    else:
        lst.append(cnt)
        cnt=0

lst.append(cnt)

ans=n-sum(lst)-1

lst2=[]
for i in lst:
    for j in range(i//2):
        lst2.append(2)
    
    if i%2==1:
        lst2.append(1)

lst2.sort()
lst2.reverse()

if len(lst2)>k:
    ans+=sum(lst2[:k])
else:
    ans+=sum(lst2)


print(ans)
//  [java]
import java.io.*;
import java.util.*;

public class Main
{
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok;

    public void go() throws IOException
    {
        ntok();
        int n = ipar();
        int k = ipar();
        ntok();
        char[] s = spar().toCharArray();
        long happy = 0;
        for (int i = 0; i < n-1; i++)
        {
            if (s[i] == s[i+1])
            {
                happy++;
            }
        }
        out.println(Math.min(n-1, happy + 2*k));

        out.flush();
        in.close();
    }

    public void ntok() throws IOException
    {
        tok = new StringTokenizer(in.readLine());
    }

    public int ipar()
    {
        return Integer.parseInt(tok.nextToken());
    }

    public int[] iapar(int n)
    {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = ipar();
        }
        return arr;
    }

    public long lpar()
    {
        return Long.parseLong(tok.nextToken());
    }

    public long[] lapar(int n)
    {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = lpar();
        }
        return arr;
    }

    public double dpar()
    {
        return Double.parseDouble(tok.nextToken());
    }

    public String spar()
    {
        return tok.nextToken();
    }

    public static void main(String[] args) throws IOException
    {
        new Main().go();
    }
}
//  [java]
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static int ans;
	static int[] parent;//union-find用
	static int[] rank;//union-find用

	public static void main(String[] args) throws IOException {
		//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//		String W	 = in.readLine();
		//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();
		boolean[] happy= new boolean[N-1];
		int unHappy = 0;

		for(int i = 0;i<N-1 ; i++) {
			if(i==N-2) {
				happy[i]= (S.charAt(i)==S.charAt(i+1)) && S.charAt(i)=='L';
			}
			happy[i] = S.charAt(i)==S.charAt(i+1);
			if(!happy[i]) {
				unHappy++;
			}
		}
		ans = N - unHappy + 2*K-1;


				System.out.println(Integer.min(ans, N));
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}

	//Union-Find用の配列を要素数nで初期化
	static void ufInit(int n){
		parent = new int[n];
		rank = new int[n];
	}

	//Union-Findの要素の最上位の親（グループ名）を返す
	static int ufFind(int a) {
		if(parent[a]==a) {
			return a;
		}else {
			return ufFind(parent[a]);
		}
	}

	//Union-Find木を連結する
	static void ufUnite(int a, int b) {
		a = parent[a];
		b = parent[b];

		if(a==b) {
			return;
		}
		if(rank[a] > rank[b]){
			parent[b]=a;
		}else {
			parent[a]=b;
			if(rank[a]==rank[b]) {
				rank[b]++;
			}
		}
	}

	static boolean ufSame(int a, int b) {
		return ufFind(a)==ufFind(b);
	}
}
//  [cpp]
#include <bits/stdc++.h>
using Int = long long int;
using namespace std;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    Int n, k;
    char s[100000];
    cin >> n >> k;
    cin >> s;
    
    Int cnt = 0;
    for(Int i=1; i<n; i++){
        if(s[i-1] == s[i]) cnt++;
    }
    cout << min(n-1, cnt + 2*k) << endl;
    return 0;
}
//  [cpp]
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
	int n, k, batas, sum = 0;
	char s[100010];
	scanf("%d %d %s", &n, &k, s);
	for (int i = 0; i < n; i++) {
		batas = i;
		while (batas + 1 < n) {
			if (s[batas + 1] != s[batas])
				break;
			batas++;
		}
		sum += (batas - i);
		i = batas;
	}
	sum = min(n - 1, sum + k + k);
	printf("%d\n", sum);
	return 0;
}
//  [cpp]
#include<stdio.h>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int N, K;
	char s[200010];
	int count = 0,mcount=0;
	scanf("%d%d%s", &N, &K, s);
	for (int i = 0; i < N - 1; i++) {
		if (s[i] == s[i + 1]) {
			count++;
		}
		else {
			mcount++;
		}
	}
	if (2 * K <= mcount) {
		printf("%d", count + 2 * K);
		return 0;
	}
	else {
			printf("%d", count + mcount);
			return 0;
	}
}