jiahuimbzuai/CoQuIR huggingface dataset:
//  [c]
#include <stdio.h>

int main()
{
    int N;
    int temp;
    int temp2;
    int ans;

    scanf("%d\n",&N);

    ans=0;
    temp=N/1000;

    if(temp==2){
        ans++;
    }    

    temp2=N%1000;
    temp=temp2/100;

    if(temp==2){
        ans++;
    }    

    temp2=temp2%100;
    temp=temp2/10;

    if(temp==2){
        ans++;
    }    

    temp2=N%10;

    if(temp2==2){
        ans++;
    }    

    printf("%d\n",ans);

    return 0;
}
//  [javascript]
function Main(input) {
	input = input.trim();
  var output = 0;
  for(var i = 0; i < input.length; i++){
    var tmp = input.slice(i , i + 1);
    if(tmp == "2"){
       output++;
       }
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input) {
  var input_num = Number(input);

  var two_count = 0;
  while(input_num > 0) {
    if (input_num %10 == 2) { 
      two_count++;
    }
    input_num = Math.floor(input_num / 10);
  }
  console.log(two_count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
  input = input.split("\n");
  S= input[0].split("");
  var ans=0;
  for(i=0;i<S.length;i++){
    if(S[i]=="2"){
      ans++;
    }
  }

  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'

const main = (INPUT) => {
  const N = INPUT.split('\n')[0]
  let cnt = 0
  for (let i = 0; i < N.length; i++) {
    if (N[i] == 2) {
      cnt++
    }
  }
  console.log(cnt)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
function main(input){
    lines = input.split("");

    var count=0;
    for(var i=0;i<4;i++){
        if(lines[i]==2){
            count++;
        }
    }

    console.log(count);
}

main(require('fs').readFileSync('/dev/stdin','utf8'));
//  [javascript]
function Main(input) {
  // 入力
  var targetStr = '2';
  var count = (input.match(new RegExp(targetStr, 'g'))||[]).length;
	//出力
	console.log('%d', count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import "fmt"

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

	xm := make(map[rune]int)
	for _, r := range n {
		xm[r]++
	}
	fmt.Println(xm['2'])
}
//  [go]
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	ans := 0
	for i := 0; i < 4; i++ {
		if s[i] == '2' {
			ans++
		}
	}
	fmt.Fprintln(writer, ans)
}
//  [go]
package main

import "fmt"

func main() {
	var N int
	fmt.Scanln(&N)
	i:=0
	for ;N!=0 ;N/=10{
		if N%10==2 {
			i++
		}
	}
	fmt.Println(i)
}
//  [go]
package main

import "fmt"

func main() {
	// Code for A - 12/22
	var N string
	fmt.Scanf("%s", &N)

	var count int
	for i := 0; i < 4; i++ {
		if N[i] == '2' {
			count++
		}
	}

	fmt.Println(count)
}
//  [go]
package main

import "fmt"

func main() {
	var n string
	fmt.Scan(&n)
	ans := 0
	for _, nn := range n {
		if nn == '2' {
			ans++
		}
	}
	fmt.Println(ans)
}
//  [ruby]
puts readline.chomp.each_char.count {|c| c == '2' }
//  [ruby]
p gets.count("2")
//  [ruby]
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  puts InputLine.to_s.split('').map(&:to_i).count(2).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end
//  [ruby]
p`dd`.chars.count{_1==?2}
//  [ruby]
p`dd`.count ?2
//  [ruby]
puts gets.chomp.split('').count{_1=='2'}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
    }
    let mut ans = 0;
    if n / 1000 == 2 {
        ans += 1;
    }
    if n % 1000 / 100 == 2 {
        ans += 1;
    }
    if n % 100 / 10 == 2 {
        ans += 1;
    }
    if n % 10 == 2 {
        ans += 1;
    }
    println!("{}", ans);
}
//  [rust]
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::cmp;

struct Scanner<'a> {
    cin : StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin : StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main(){
	let cin = stdin();
	let cin = cin.lock();
	let mut sc = Scanner::new(cin);
	let n : usize = sc.read();
        println!("{}", n.to_string().chars().fold(0, |acc, x| acc + if x.to_digit(10).unwrap() == 2 { 1 } else { 0 }));
	
}
//  [rust]
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<String>();
    let ans = n.chars().filter(|&x| x == '2').count();
    println!("{}", ans);
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
//  [rust]
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;
use std::cmp;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let S: String = sc.read();
    let mut ans = 0;
    for i in 0..S.len() {
        if S.chars().nth(i).unwrap() == '2' { ans += 1; }
    }
    println!("{}", ans);
}
//  [rust]
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        s: Chars,
    }
    println!("{}", s.iter().filter(|&c| *c == '2').count());
}
//  [swift]
print(readLine()!.characters.filter{$0=="2"}.count)
//  [swift]

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

enum NumError: Error {
    case invalid(String)
}

extension NumError: LocalizedError {
    var errorDescription: String? {
        switch self {
        case .invalid(let errorMessage):
            return errorMessage
        }
    }
}

func caddi2018b_aa() throws -> Int {
    let N = readInt()
    
    if N < 999 {
        throw NumError.invalid("1000から9999の値を入れてください")
    }
    
    if N >= 10000 {
        throw NumError.invalid("1000から9999の値を入れてください")
    }
    
    return String(N).map {$0}.filter {$0 == "2"}.count
}

func caddi2018b_a() -> Result<Int, NumError> {
    let N = readInt()
    
    if N < 999 {
        return .failure(.invalid("1000から9999の値を入れてください"))
    }
    
    if N >= 10000 {
        return .failure(.invalid("1000から9999の値を入れてください"))
    }
    
    return .success(String(N).map {$0}.filter {$0 == "2"}.count)
}

let ans = caddi2018b_a()
switch ans {
case .failure(let error):
    print(error.localizedDescription)
case .success(let ans):
    print(ans)
}

//do {
//    try print(caddi2018b_a())
//} catch NumError.invalid(let errorMessage) {
//    print(errorMessage)
//}
//  [typescript]
s=require('fs').readFileSync('/dev/stdin','utf8').split('')
r = 0
s.filter(n=>n == '2').map(n=>r++)
console.log(r)
//  [typescript]
"use strict";

const main = arg => {
  const input = arg.trim().split("\n")[0];
  let c = 0;
  for (let i = 0; i < 4; i++) {
    if (input.substring(i,  i +1 ) === "2") {
      c ++;
    }
  }
  console.log(c);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
import numpy as np

bus = input()

if bus == "AAA":
    print("No")
elif bus == "BBB":
    print("No")
else:
    print("Yes")
//  [python]
import sys
import numpy as np

# input = sys.stdin.readline

s = input()

if (s == "AAA") or (s == "BBB"):
    print("No")
else:
    print("Yes")
//  [python]
import numpy as np
S = str(input().split())

if ('A' in S) & ('B' in S):
    print('Yes')
else:
    print('No')
//  [java]

import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final String s = scanner.next();
        final long count = IntStream.range(0, 3)
                .mapToObj(s::charAt)
                .distinct()
                .count();

        if(count == 1){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}
//  [java]
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        // int N = Integer.parseInt(s.next());
        String S = s.next();
        List<String> ret = Arrays.asList(S.split("")).stream().distinct().collect(Collectors.toList());
        System.out.println(ret.size() == 1 ? "No" : "Yes");
    }
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * for (int i = 0; i < N; i++) {}
 * System.out.println();
 * @author mj
 *
 */
public class Main implements Runnable { //クラス名はMain1

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	public void run() {
		FastScannerMain1 sc = new FastScannerMain1(System.in);

		try {
			String S = sc.nextLine().trim();
			boolean a = false;
			boolean b = false;

			if (S.contains("A")) {
				a = true;
			}
			if (S.contains("B")) {
				b = true;
			}

			if (a && b) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}

		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}

//高速なScanner
class FastScannerMain1 {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMain1(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
using lint = long long;
int main() {
	string N;
	cin >> N;
	cou((N == "AAA" || N == "BBB" ? "No" : "Yes"));
	rep(i, 1000) {
		rep(j, 1006) {
			rep(k, 135) {
				N = "処理";
			}
		}
	}
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
using lint = long long;
int main() {
	string N;
	cin >> N;
	cou((N == "AAA" || N == "BBB" ? "No" : "Yes"));
	rep(i, 1000) {
		rep(j, 1005) {
			rep(k, 135) {
				N = "処理";
			}
		}
	}
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
using lint = long long;
int main() {
	string N;
	cin >> N;
	cou((N == "AAA" || N == "BBB" ? "No" : "Yes"));
	rep(i, 1000) {
		rep(j, 1000) {
			rep(k, 135) {
				N = "処理";
			}
		}
	}
}
//  [c]
#include <stdio.h>
int main(void){
    // Your code here!
    char c[3];
    scanf("%c%c%c",&c[0],&c[1],&c[2]);
    
    if(c[0]==c[1]&&c[1]==c[2])
        puts("No");
    else
        puts("Yes");
    return 0;
}
//  [c]
#include <stdio.h>
int main(void) {
  char S[3];
  scanf("%s", S);
  if (S[0] == S[1] && S[1] == S[2]) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }
  return 0;
}
//  [c]
#include <stdio.h>

int main(){
  
  char S[10];
  scanf("%s",S);
  if(S[0]==S[1] && S[0]==S[2]){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}
//  [javascript]
function Main(arg)
{
  var N = arg.split("\n")[0];

  if (N === "AAA" || N === "BBB") {
    console.log("No");
  }
  else {
  console.log("Yes");    
  }
  return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
function main(input) {
  let s = input[0];

  if((s.indexOf("A")===-1) || (s.indexOf("B")===-1)){
    console.log("No");
  }else{
    console.log("Yes");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));
//  [javascript]
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var s = next();
  if(s.indexOf("A") == -1 || s.indexOf("B") == -1){
     myout("No");
     }else{
      myout("Yes"); 
     }
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	if s == "AAA" || s == "BBB" {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}
//  [go]
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	if strings.Count(s, "A") != 0 && strings.Count(s, "B") != 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()

	S := strings.Split(scanner.Text(), "")

	if S[0] != S[1] || S[1] != S[2] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}
//  [ruby]
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

S = gets.chomp

if S.include?('A') && S.include?('B')
  puts 'Yes'
else
  puts 'No'
end
//  [ruby]
s=gets
puts s[?A]&&s[?B] ? :Yes : :No
//  [ruby]
s = gets().chomp

puts s.split('').uniq.length == 1 ? 'No' : 'Yes'
//  [swift]
import Foundation

/*
// 1
let N = Int(readLine()!)!

// 1 2
let split = readLine()!.componentsSeparatedByString(" ")
let N = Int(split[0])!
let S = Int(split[1])!

// 1 2 3 4 5
let array = readLine()!.componentsSeparatedByString(" ").map { Int($0)! }

func pow(_ number: Int, multiplier: Int) -> Int {
  var answer = 1
  for _ in 0 ..< multiplier {
    answer *= number 
  }
  return answer
}


*/
let N = readLine()!
let A = "AAA"
let B = "BBB"
if N == A || N == B{
  print("No")
} else {
print("Yes")
}
//  [swift]
import Foundation
let s:String = readLine()!
print(s.contains("AB") || s.contains("BA") ? "Yes":"No")
//  [swift]
import Foundation

func main() {
    let s = readLine()! .map { String($0) }
    print(s.filter { $0 == "A" }.count == 0 || s.filter { $0 == "B" }.count == 0 ? "No": "Yes")
}
main()
//  [typescript]
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let s: string = "";
    let ans: string = "";
    // init
    s = input.shift();
    // solve
    ans = (s == "AAA" || s == "BBB") ? "No" : "Yes";
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();
//  [typescript]
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const s = input[0];

console.log(["AAA","BBB"].indexOf(s) === -1 ? "Yes": "No");
//  [typescript]
function Main(input) {
    const lines = input.split("\n");
    const s = lines[0];

    console.log(s == 'AAA' || s == 'BBB' ? 'No' : 'Yes');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [python]
import sys
readline = sys.stdin.readline

def merge(A, B):
    res = [[inf]*26 for _ in range(26)]
    for i in range(26):
        for j1 in range(26):
            for j2 in range(26):
                if j1 == j2:
                    continue
                for k in range(26):
                    res[i][k] = min(res[i][k], A[i][j1]+B[j2][k])
    return res
S = list(map(lambda x: ord(x) - 97, readline().strip()))
K = int(readline())
inf = 10**18+13
dp = [None]*26

for st in range(26):
    Dp = [inf]*26
    if st == S[0]:
        Dp[st] = 0
    else:
        Dp[st] = 1
    for s in S[1:]:
        Dp2 = [inf]*26
        for i in range(26):
            for j in range(26):
                if i == j:
                    continue
                if s != i:
                    Dp2[i] = min(Dp2[i], Dp[j] + 1)
                else:
                    Dp2[i] = min(Dp2[i], Dp[j])
        Dp = Dp2[:]
    dp[st] = Dp[:]

stack = [dp]

for _ in range(32):
    stack.append(merge(stack[-1], stack[-1]))

E = [[0]*26 for _ in range(26)]
for i in range(32):
    if (1<<i) & K:
        E = merge(E, stack[i])
print(min(min(d) for d in E))
//  [python]
import numpy as np
S = input()
K = int(input())
seq = []
init = 1
def seq_count(strings, lst):
    init = 1
    for i in range(len(strings)-1):
        if strings[i] == strings[i+1]:
            init += 1
        else:
            lst.append(init)
            init = 1
    lst.append(init)
seq_count(S, seq)
if S[0] != S[-1]:
    array = np.array(seq)
    ans = array // 2
    print(int(np.sum(ans))*K) 
else:
    seq2 = seq[1:-1]
    array = np.array(seq2)
    part_ans = array // 2
    if len(seq) > 1:
        print(int(np.sum(part_ans))*K+((seq[0]+seq[-1])//2)*(K-1)+(seq[0]//2)+(seq[-1]//2))
    else:
        print((seq[0]*K)//2)
//  [python]
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, pdb
sys.setrecursionlimit(10**7)
from queue import PriorityQueue
from fractions import gcd
inf, eps, mod = 10 ** 20, 1.0 / 10**10, 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def _cumsum(l): return list(itertools.accumulate(l)) 
"""
なかのものと端のもの
両端が一緒かどうか
一緒なら、K-1個変える
中を変える/2切り下げ
まず、端が一緒か
"""
S = input()
K = _I()
ans = 0

if len(set(S)) == 1:
    print(int(math.floor(len(S)*K/2)))
    exit()

S2 = S*2
S3 = S*3

torn_list_1 = []
previous = 'hoge'
for s in S2:
    if s == previous:
        torn_list_1[-1] += 1
    else:
        torn_list_1.append(1)
        previous = s
torn_list_2 = []
previous = 'hoge'
for s in S3:
    if s == previous:
        torn_list_2[-1] += 1
    else:
        torn_list_2.append(1)
        previous = s

ans2 = 0
ans3 = 0
for t in torn_list_1:
    if t>=2:
        ans2+=int(math.floor(t/2))

for t in torn_list_2:
    if t>=2:
        ans3+=int(math.floor(t/2))

diff = ans3-ans2

ans = ans2 + (K-2)*diff
print(ans)
//  [java]
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long k = sc.nextLong();
        sc.close();
        int len = s.length();
        if (len == 1) {
            System.out.println(k / 2);
            return;
        }
        char tmp = s.charAt(0);
        int cnt = 1;
        long ans = 0;
        List<Integer> list = new ArrayList<>();
        char c = s.charAt(1);
        for (int i = 1; i < len; i++) {
            while (true) {
                c = s.charAt(i);
                // System.out.println(c);
                if (c != tmp) {
                    break;
                }
                cnt++;
                i++;
                if (i == len) {
                    break;
                }
            }
            list.add(cnt);
            cnt = 1;
            tmp = c;
            // 異なる状態になる
        }
        if (s.charAt(len - 1) != s.charAt(len - 2)) {
            list.add(1);
        }
        if (list.size() == 1) {
            int num = list.get(0);
            if (num % 2 == 0) {
                ans += (num / 2) * k;
            } else {
                int num2 = num + 1;
                for (int i = 0; i < k; i++) {
                    if (i % 2 == 0) {
                        ans += num / 2;

                    } else {
                        ans += num2 / 2;
                    }
                }
            }
        } else if (s.charAt(0) != s.charAt(len - 1)) {
            for (int i : list) {
                // System.out.println(i);
                ans += (i / 2) * k;
            }
        } else {
            int size = list.size();
            for (int i = 1; i < size - 1; i++) {
                ans += (list.get(i) / 2) * k;
            }
            int f = list.get(0);
            int l = list.get(size - 1);
            int wa = f + l;
            ans += (wa / 2) * (k - 1);
            ans += f / 2;
            ans += l / 2;
        }
        System.out.println(ans);

    }
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.stream.IntStream;

public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        String s = stdin.readLine();
        long k = Long.parseLong(stdin.readLine());

        if (IntStream.range(0, s.length()).allMatch(i -> s.charAt(0) == s.charAt(i))) {
            stdout.println(s.length() * k / 2);
            return ;
        }

        char[] t = s.toCharArray();
        long c = 0;
        for (int i = 1; i < t.length; i++) {
            if (t[i - 1] == t[i]) {
                t[i] = '@';
                c++;
            }
        }

        if (s.charAt(0) == s.charAt(s.length() - 1)) {
            long a = 0;
            long b = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(0) != s.charAt(i)) break;
                a++;
            }
            for (int i = s.length() - 1; i >= 0; i--) {
                if (s.charAt(s.length() - 1) != s.charAt(i)) break;
                b++;
            }
            stdout.println(c * k - (a / 2 + b / 2 - (a + b) / 2) * (k - 1));
        } else {
            stdout.println(c * k);
        }
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}
//  [cpp]
#include <bits/stdc++.h>

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999
using namespace std;
#define lint long long

int mee(int i1,int ret, string& s)
{
  if(s[i1] == s[i1+1]) {
    ++ret;
    ret = mee(i1+1,ret,s);
  }
  return ret;
}
int main()
{
  string s1; cin >> s1;
  string s2 = s1+s1;
  string s3 = s2 + s1;
  lint k; cin >> k;
  lint m1 = s1.length()-1;
  lint m2 = s2.length()-1;
  lint m3 = s3.length()-1;
  vector<lint> me1(m1,1);
  vector<lint> me2(m2,1);
  vector<lint> me3(m3,1);
  lint count1 = 0;
  lint count2 = 0;
  lint count3 = 0;
  REP(i,m1){
    if(s1[i] == s1[i+1]) {
      lint ret = 1;
      ret = mee(i+1,ret,s1);
      me1[i] += ret;
      i+=ret;
  	}
  }
  REP(i,m2){
    if(s2[i] == s2[i+1]) {
      lint ret = 1;
      ret = mee(i+1,ret,s2);
      me2[i] += ret;
      i+=ret;
  	}
  }
  REP(i,m3){
    if(s3[i] == s3[i+1]) {
      lint ret = 1;
      ret = mee(i+1,ret,s3);
      me3[i] += ret;
      i+=ret;
  	}
  }
  REP(i,m1){
    if(me1[i] > 1) count1 +=me1[i]/2;
  }
  REP(i,m2){
    if(me2[i] > 1) count2 +=me2[i]/2;
  }
  REP(i,m3){
    if(me3[i] > 1) count3 +=me3[i]/2;
  }
  lint c1 = count3 - count2;
  lint c2 = count2 - count1;
  //cout << c1 << "  " << c2 << "\n";
  if(c1 != c2){
  	FOR(i,1,k){
      if(i%2 == 0){
  		count1 += c1;
      }else{
        count1 += c2;
      }
  	}
  }else{
    count1 += (count2 - count1)*(k-1);
  }
  cout << count1;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;


int main(void){
    
    string S;
    long long K;
    cin >> S >> K;
    
    long long cont = 0;
    long long contS = 0;
    long long contE = 0;

    
    if(K == 1){
        

        
        for(int i = 0; i < S.size();i++){
            if(i != S.size()-1){
                if(S[i] == S[i+1]){
                    S[i+1] = '#';
                    cont++;
                }
            }
        }
        cout << cont << endl;   
        return 0;            
    }
    

        
    if(S[0]==S[S.size()-1]){
        
        contS = 1;
        contE = 1;
            
        while(S[contS-1] == S[contS])contS++;
        while(S[S.size() - contE] == S[S.size() - contE - 1])contE++;
        
        if(S.size()==contS){
            
            if(S.size()==1){
                cout << K/2 <<endl;
                return 0;
            }
            
            if(S.size()%2==0)cout << (S.size()/2)*K <<endl;
            else{
                long long difA = S.size()/2;
                long long difB = S.size() - difA;
                //cout << difA <<" "<<difB<<endl;
                long long sum = 0;
                for(int i = 0; i < K;i++){
                    if(i%2==0)sum += difA;
                    else sum += difB;
                }
                cout << sum <<endl;
                
            } 
            return 0;
        }
    }
        
    for(int i = contS; i < S.size()-contE;i++){
        if(i != S.size()-1){
            if(S[i] == S[i+1]){
                S[i+1] = '#';
                cont++;
            }
        }else{
            if(S[0] == S[i]){
                S[0] = '#';
                cont++;
            }
        }
    }
    // cout <<contS<<endl;
    // cout <<contE<<endl;
    cout << cont * K + (contS+contE)/2*(K-1)+ contS/2+contE/2 <<endl;
    
}
//  [c]
#include <stdio.h>
#include <string.h>


int main(void)
{
    long k,cnt=0,ans=0;
    char s[100];
    scanf("%s",s);
    scanf("%ld",&k);
    long len=strlen(s);
    int a=0;
    for(int i=1;i<len;i++)
    {
        if(s[i-1]==s[i])
        {
            if(a==0)
            {
                cnt++;
                a=1;
            }else{
                a=0;
            }
        }else{
            a=0;
        }
    }
    if(s[0]!=s[len-1])
    {
        ans=cnt*k;
    }else{
        int key=1;
        for(int i=1;i<len;i++)
        {
            if(s[i]==s[i-1])
            {
                key++;
            }else{
                break;
            }
        }
        if(key==len){
            ans=len*k/2;
        }else{
            long sum=0,j=0,i=len-1;
            while(s[0]==s[j]&&j<len)
            {
                j++;
                sum++;
            }
            while(s[len-1]==s[i]&&i>=0)
            {
                i--;
                sum++;
            }
            ans=cnt*k+((sum+1)%2)*(k-1);
        }
    }
    
    printf("%ld\n",ans);
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)

int main(){
    //input
    char s[105];
    scanf("%s", s);
    int k;
    scanf("%d", &k);

    //solve
    ll ans = 0;
    int n = strlen(s);
    char t[205];
    rep(i, 2*n) t[i] = s[i%n];
    int allsame = 1;
    rep(i, n-1) if(s[i] != s[i+1]) allsame = 0;
    if(allsame){
        ans = (ll)n * k / 2;
    }else{
        rep(i, n){
            if(t[i] == t[i+1]){
                if(i+1 < n) ans += k;
                else{
                    int tmp = i+1;
                    while(tmp + 1 < 2*n && t[tmp] == t[tmp+1]) tmp++;
                    if((tmp - i) % 2 == 1) ans += k-1;
                    break;
                }
                i++;
            }
        }
    }
    
    //output
    printf("%lld", ans);
}
//  [c]
#include <stdio.h>
#include <inttypes.h>

char S[128];
int K;

int nyan = 0;
int kugyu[128];
char mimorin[128];

int main(void) {
	int i, horieyui;
	int64_t mareitaso = 0;
	if (scanf("%127s", S) != 1) return 1;
	if (scanf("%d", &K) != 1) return 1;
	horieyui = 1;
	for (i = 1; S[i - 1] != '\0'; i++) {
		if (S[i - 1] != S[i]) {
			kugyu[nyan] = horieyui;
			mimorin[nyan] = S[i - 1];
			nyan++;
			horieyui = 1;
		} else {
			horieyui++;
		}
	}
	if (nyan < 1) {
		puts("ERROR!");
		return 2;
	} else if (nyan == 1) {
		int64_t yukati = (int64_t)kugyu[0] * K;
		mareitaso += yukati / 2;
	} else if (mimorin[0] == mimorin[nyan - 1]) {
		for (i = 1; i < nyan - 1; i++) {
			mareitaso += kugyu[i] / 2;
		}
		mareitaso *= K;
		mareitaso += ((int64_t)(kugyu[0] + kugyu[nyan - 1]) / 2) * (K - 1);
		mareitaso += kugyu[0] / 2;
		mareitaso += kugyu[nyan - 1] / 2;
	} else {
		for (i = 0; i < nyan; i++) {
			mareitaso += kugyu[i] / 2;
		}
		mareitaso *= K;
	}
	printf("%" PRId64 "\n", mareitaso);
	return 0;
}
//  [javascript]
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var s = o.a(1);
  var n = s.length;
  var k = o.a();
  var ans = 0, t = s[0], u = 1;
  var a = [];
  for(var i = 1; i < n; i++){
    if(t === s[i])u++;
    else{
      a.push(u);
      ans += Math.floor(u/2);
      u = 1;
      t = s[i];
    }
  }
  a.push(u);
  ans += Math.floor(u/2);
  if(k === 1)return ans;
  if(s[0] !== s[n-1])return ans*k;
  if(a.length === 1)return Math.floor(a[0]*k/2);
  ans = 0;
  var m = a.length;
  for(var i = 1; i < m-1; i++){
    ans += Math.floor(a[i]/2);
  }
  ans *= k;
  ans += Math.floor(a[0]/2);
  ans += Math.floor(a[m-1]/2);
  ans += Math.floor((a[0]+a[m-1])/2)*(k-1);
  return ans;
}
//  [javascript]
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var s = next();
  var N = nextInt();
  var len = s.length;
  if(len == 1){
    myout(Math.floor((len * N) / 2));
    return;
  }
  var isAllSame = true;
  var s1 = myconv(s, 6);
  var s2 = myconv(s + s, 6);
  
  var output = 0;
  var s1count = 0;
  var s2count = 0;
  
  for(var i = 1; i < s1.length; i++){
    var mae = s1[i - 1];
    var ato = s1[i];
    if(mae != ato){
       isAllSame = false;
       break;
    }
  }
  
  if(isAllSame){
    myout(Math.floor(N * len / 2));
    return
  }
  
  for(var i = 1; i < s1.length; i++){
    var mae = s1[i - 1];
    var ato = s1[i];
    if(mae == ato){
       s1count++;
       s1[i] = "X";
    }
  }
  for(var i = 1; i < s2.length; i++){
    var mae = s2[i - 1];
    var ato = s2[i];
    if(mae == ato){
       s2count++;
       s2[i] = "X";
    }
  }
  if(N == 1){
    myout(s1count);
  }else{
    myout((s2count - s1count) * (N - 1) + s1count);
  }
  
}
//  [go]
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanRunes()
	k := scanInt()
	a, b := 0, 0
	s = append(s, s...)
	for i := 0; i < len(s)-1; i++ {
		if s[i] == s[i+1] {
			s[i+1] = '@'
			if i+1 < len(s)/2 {
				a++
			} else {
				b++
			}
		}
	}
	if s[0] == s[len(s)-1] {
		fmt.Fprintln(wr, a+b*(k-1))
	} else {
		fmt.Fprintln(wr, (k+1)/2*a+k/2*b)
	}
}
//  [go]
package main

import "fmt"

func main() {
	// Code for A - Connection and Disconnection
	var S string
	var K int
	fmt.Scan(&S, &K)

	var count1, count2 int
	var flag int
	for i := 0; i < len(S)-1; i++ {
		if S[i] == S[i+1] {
			count1++
			i++
		}

		if S[i] != S[0] {
			flag++
		}
	}

	if flag == 0 {
		fmt.Println(len(S) * K / 2)
	} else if S[0] != S[len(S)-1] {
		fmt.Println(count1 * K)
	} else {
		count2 = 0
		T := S + S
		for i := 0; i < len(T)-1; i++ {
			if T[i] == T[i+1] {
				count2++
				i++
			}
		}

		fmt.Println((K-1)*(count2-count1) + count1)
	}

}
//  [ruby]
def change_count (array, multiple)
  chars = array * multiple
  change_count = 0
  (1...chars.size).each do |i|
    if chars[i - 1] == chars[i]
      chars[i] = 'A'
      change_count += 1
    end
  end
  change_count
end

INF = 10 ** 9
s = gets.chomp.split("")
k = gets.to_i
first_change_count = change_count(s, 1)
cycle = []
(2..INF).each do |i|
  increment_change_count = change_count(s, i) - (first_change_count + cycle.sum)
  break if cycle.first == increment_change_count
  cycle << increment_change_count
end

ans = first_change_count
k -= 1

div, mod = k.divmod(cycle.size)
ans += cycle.sum * div
ans += cycle[0...mod].sum

puts ans
//  [ruby]
def cal(t, u)
  num = 0
  t.length.times do |i|
    num += u[i] / 2
  end
  num
end

s = gets.chomp.split('')
k = gets.to_i
t = [s[0]]
u = []
y = s[0]
num = 1
s[1..-1].each do |x|
  if x != y
    u << num
    t << x
    y = x
    num = 1
  else
    num += 1
  end
end
u << num

if t.length == 1
  puts k * u[0] / 2
elsif t[0] == t[-1]
  num = cal(t, u) * k
  x = u[0]/2 + u[-1]/2 - (u[0] + u[-1]) / 2
  num -= x * (k-1)
  puts num
else
  puts cal(t, u) * k
end
//  [ruby]
s = gets.chomp.chars
k = gets.to_i
n = s.size

i = 0
chunk = []
cur = s[i]
cnt = 1
i += 1
i.step(n - 1) do |j|
  if s[j] == cur
    cnt += 1
  else
    chunk << cnt
    cnt = 1
    cur = s[j]
  end
end
chunk << cnt

res = 0
if chunk.size == 1
  res += n * k / 2
else
  if s[0] == s[-1]
    pr = chunk.shift
    su = chunk.pop
    res += pr / 2
    res += su / 2
    res += ((pr + su) / 2) * (k - 1)
  end
  
  chunk.each do |c|
    res += (c / 2) * k
  end
end
puts res
//  [python]
R = int(input())
G = int(input())

print(2 * G - R)
//  [python]
R=int(input())
G=int(input())
print((2*G)-R)
//  [python]
R=int(input())
G=int(input())

print(2*G-R)
//  [python]
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    r = I()
    g = I()

    return r+(g-r)*2


print(main())
//  [python]
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    R=I()
    G=I()
    print(G+(G-R))

if __name__ == '__main__':
    main()
//  [python]
import numpy as np
lst = []

R = int(input())
G = int(input())


ans = G - R + G
print(ans)
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			int R = Integer.parseInt(str);
			str = br.readLine();
			int G = Integer.parseInt(str);
			System.out.println(2*G - R);
//			long max  = 1000000007;
		}catch (Exception e) {
			System.exit(0);
		}
	}

}
//  [java]

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
		String strR = bufferedReader.readLine();
		String strG = bufferedReader.readLine();
		int r = Integer.parseInt(strR);
		int g = Integer.parseInt(strG);

		int answer = g * 2 - r;
		System.out.println(answer);
	}

}
//  [java]
import java.util.Scanner;

public class Main{
  static int r, g;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    r = sc.nextInt();
    g = sc.nextInt();

    System.out.println(2 * g - r);
  }
}
//  [java]
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.swing.text.Segment;

public class Main {

	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final long R = sc.nextLong();
			final long G = sc.nextLong();
			
			final long diff = G - R;
			System.out.println(G + diff);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}