jiahuimbzuai/CoQuIR huggingface dataset:
//  [rust]
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn gcd(a: i32, b: i32) -> i32 {
    fn gcd1(m: i32, n: i32) -> i32 {
        if n == 0 {
            m
        } else {
            gcd1(n, m % n)
        }
    }
    if a > b {
        gcd1(a, b)
    } else {
        gcd1(b, a)
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0i32; n];
    for i in 0..n - 1 {
        av[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    av[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = av[0];
    for i in 1..n {
        ans = gcd(ans, av[i]);
    }
    println!("{}", ans);
}
//  [rust]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u128; n]
    };

    let mut a: Vec<u128> = a;
    a.sort();
    a.dedup();

    let mut result = a[0];

    if a.len() > 1 {
        for i in 1..n {
            result = gdg(result, a[i]);
        }
    }

    println!("{}", result)
}

fn gdg(a: u128, b: u128) -> u128 {
    let mut a = a;
    let mut b = b;

    if a > b {
        let tmp = a;
        a = b;
        b = tmp;
    }

    let mut r = a % b;

    while r != 0 {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}
//  [rust]
use proconio::{input, fastout};
#[fastout]
fn main() {
    input!{
        n: usize,
        mut a: [usize;n],
    }

    a.sort();
    for i in 0..n {
        if a[i]%a[0]!=0 {
            println!("1");
            return;
        } 
    }
    println!("{}", a[0]);
}
//  [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 gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = vec![];
    for _ in 0..n {
        a.push(read());
    }

    let ans = a[0];

    for i in 0..a.len() {
        let ai = a[i];
        gcd(ai, ans);
    }
    println!("{}", ans);
}
//  [swift]
import Foundation
//最大公約数を求める関数
func gcd(_ num1: Int, _ num2: Int) -> Int {
   let r = num1 % num2
   if r != 0 {
       return gcd(num2, r)
   } else {
       return num2
   }
}
//３つ以上の数の最大公約数を求める
func gcdArr(_ numArr: [Int]) -> Int {
    var ans: Int = numArr[0]
    for i in numArr {
        ans = gcd(ans, i)
    }
    return ans
}

//最小公倍数を求める関数
func lcm(_ num1: Int, _ num2: Int) -> Int {
    
    var gcdNum = gcd(num1, num2)
    return num1*num2/gcdNum
}

//３つ以上の最大公約数を求める
func lcmArr(_ numArr: [Int]) -> Int {
    var ans: Int = 1
    for i in numArr {
        ans = lcm(ans, i)
    }
    return ans
}


let ri = Int(readLine()!)!
let ra = readLine()!.split(separator: " ").map({Int($0)!})
print(gcdArr(ra))
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}
///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    var aryA = readInts().sorted()
    var mi = Int.max
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    for i in 1..<n {
        let surplus = aryA[i] % aryA[0]
        if surplus > 0 {
            mi = min(mi, surplus)
        }
    }
    
    while aryA[0] > 1 && mi > 1 && mi < Int.max{
        if aryA[0] > mi {
            aryA[0] = aryA[0] - mi
        }
        else {
            mi = mi - aryA[0]
        }
    }
    print(aryA[0] > 0 && mi > 0 ? min(aryA[0], mi): max(aryA[0], mi))
}
main()
//  [swift]
// ユークリッドの互除法
func gcd(_ x: Int, _ y: Int) -> Int {
    if y == 0 { return x }
    return gcd(y, x % y)
}
// 再帰関数
func recursiveFunc(_ idx: Int, _ x: Int) {
    if idx == N-1 {
        print(x)
        return
    }
    recursiveFunc(idx+1, gcd(x, A[idx+1]))
}

let N = Int(readLine()!)!
let A: [Int] = readLine()!.split(separator: " ").map { Int($0)! }

recursiveFunc(1, gcd(A[0], A[1]))   // (๑•ૅㅁ•๑)
//  [swift]
import Foundation
//最大公約数を求める関数
func gcd(_ num1: Int, _ num2: Int) -> Int {
   let r = num1 % num2
   if r != 0 {
       return gcd(num2, r)
   } else {
       return num2
   }
}
//３つ以上の数の最大公約数を求める
func gcdArr(_ numArr: [Int]) -> Int {
    var ans: Int = numArr[0]
    for i in numArr {
        ans = gcd(ans, i)
    }
    return ans
}

//最小公倍数を求める関数
func lcm(_ num1: Int, _ num2: Int) -> Int {
    
    var gcdNum = gcd(num1, num2)
    return num1*num2/gcdNum
}

//３つ以上の最大公約数を求める
func lcmArr(_ numArr: [Int]) -> Int {
    var ans: Int = 1
    for i in numArr {
        ans = lcm(ans, i)
    }
    return ans
}


let ri = Int(readLine()!)!
let ra = readLine()!.split(separator: " ").map({Int($0)!})
print(lcmArr(ra))
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}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 ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;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 deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};const sum=(arr)=>{return arr.reduce((a,b)=>a+b);};const isPrime=(n:number):boolean=>{if(n<2)return false;const suq=Math.sqrt(n);for(let i=2;i<=suq;i++){if(n%i==0){return false;}}return true;};
const main=()=>{
  let n=tn(),ar=tnn(n),ans=ar[0]
  for(let i=1;i<n;i++){
    ans=gcd(ar[i],ans)
  }
  to(ans)
}
main()
//  [typescript]
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const a = input[1].split(" ").map(n => Number(n));
  const gcd = (a, b) => {
    if (b === 0) return a;
    return gcd(b, a % b);
  }
  let result = a[0];
  for (let i = 1; i < n; i++) {
  	result = gcd(result, a[i]);
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
export class Main {
  static main(input: string): string {
    const [nStr, aStr] = input.split("\n");
    const n = Number(nStr);
    const aList = aStr.split(" ").slice(0, n).map(Number);
    let result = Main.gcd(aList[0], aList[1]);
    for (let i = 2; i < n; i++) {
      if (result == 1) {
        break;
      }
      result = Main.gcd(result, aList[i]);
    }
    return `${result}`;
  }
  
  private static gcd(a: number, b: number): number {
    if (a == 0 || b == 0) {
      return 0;
    }
    let r = a;
    let tmp = b;
    while (tmp > 0) {
      let t = r % tmp;
      r = tmp;
      tmp = t;
    }
    return r;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

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

let a = stdin.split('\n')[1].split(' ').map(Number)

a.forEach((e,i)=>{
  for(let j = 0; j < a.length; j++){
    if(j !== i){
      const m = e >= a[j] ? e % a[j] : 0
      if(m){
        a[i] = m
      }
    }
  }
})

a.sort((A,B)=>A-B)
console.log(a[0])
//  [typescript]
function main(arg) {
  const _a: string[] = arg.split("\n")
  const _n: number = Number(_a[0])
  const _m: string[] = _a[1].split(" ")
  let list: number[] = []

  for (let i = 0; i < _m.length;i++) {
    list.push(Number(_m[i]))
  }

  while (list.length != 1){
    let min: number = list.reduce((a, b) => a < b ? a : b)

    if (min == 1) return console.log(min)

    for (let i = 0; i < Number(_n); i++) {
      if (list[i] - Math.floor(list[i] / min) * min > 0){
        list[i] = list[i] - Math.floor(list[i] / min) * min
      }
    };

    list = list.filter(function (x, i, self) {
      return self.indexOf(x) === i;
    });
  }

  return console.log(list[0])
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
import sys


def main():
    s = sys.stdin.readline().rstrip()

    black = 0
    ans = 0

    for i in s:
        if i == "B":
            black = black + 1
        else:
            ans = ans + black

    print(ans)


if __name__ == "__main__":
    main()
//  [python]
def main():
    S=input()
    b_n = 0; ans = 0
    for s in S:
        if s=='B': b_n += 1
        else: ans += b_n
    print(ans)
main()
//  [python]
S = input()

def f(S):
    if len(S)==1 :
        return 0
    else :
        result = 0; b = 0
        for i in S :
            if i == 'B' :
                b+=1
            else:
                result += b
        return result
print(f(S))
//  [python]

def resolve():
    S = input()
    sub = "BW"
    cnt = 0
    st = S.find("B")
    S = S[st:]
    while True:
        res = S.find(sub)
        if res == -1:
            break
        cnt += 1
        S = S[:res] + "WB" + S[res+2:]
    print(cnt)


if __name__ == "__main__":
    resolve()
//  [python]

def resolve():
    S = input()
    sub = "BW"
    cnt = 0
    while True:
        res = S.find(sub)
        if res == -1:
            break
        cnt += 1
        S = S[:res] + "WB" + S[res+2:]
    print(cnt)


if __name__ == "__main__":
    resolve()
//  [python]
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

s = S()

# n個のオセロストーンが1列にある。長さnの文字列sで石の状態はあらわされていて、
# i番目の石が白：w、黒:bであらわされている。
# 以下の操作を行う

# iがb,i+1がwなiを一つ選び、二つとも裏返す。

# 最大でこの作業を何回行うことができるか。

# 例
# bwbwbwbwbw ⇒ wbwbwbwbwb
# bwwbbbwwwbwb　⇒　wbwbbbwwwbwb　⇒ wwbbbwwwbwb　⇒ wwbbwbwwbwb　⇒ wwbwbbwwbwb　⇒
# wwwbbbwwbwb　⇒ wwwbbwbwbwb　⇒ wwwbwbbwbwb　⇒ wwwwbbbwbwb　⇒ wwwwbbbwbwb　⇒ 

# 最終的にwwwwwwbbbbbになるので、結論としてはwを左に動かした回数をカウントすればよい。
# このカウントは、左から見て行ってwが出た位置より左のbの数を足し上げればよい。
black = 0
ans = 0
for stone in s:
    if stone == "b":
        black = black + 1
    else:
        ans = ans + black
print(ans)
//  [java]
import java.io.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws IOException {
        InputStream in = System.in;
        final byte[] buffer = new byte[200001];
        int buflen = 0;
        buflen = in.read(buffer);
        int c=0;
        long s=0;
        for (int i=0; i<buflen; ++i) {
            if (buffer[i]=='B') {
                ++c;
            } else if (buffer[i]=='W') {
                s+=c;
            }
        }
       	System.out.println(s);
    }
}
//  [java]
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		int ans = 0;
		int count = 0;
		for(int i = 0;i < s.length;i++){
			if(s[i].equals("W")){
				ans += i-count;
				count++;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}
//  [java]
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		int ans = 0;
		int count = 0;
		for(int i = 0;i < s.length;i++){
			if(s[i].equals("W")){
				ans += (i-count);
				count++;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}
//  [java]
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			String S = scan.next();
			char[]s = S.toCharArray();



			int count = 0;
			int kosuu = 0;
			for(int i = s.length-1;i>=0;i--) {

				int youso = s.length-1;
				if(s[i]=='B') {
					count+=(youso-i-kosuu);
					kosuu++;
				}
			}

			System.out.println(count);

		}


	}


}
//  [cpp]
#include <stdio.h>
int main(void){
  char s[200010] = {0};
  long long c = 0, b = 0;
  fgets(s, 200010, stdin);
  for(int i = 0; s[i] != 0 && s[i] != '\n'; i++){
    if(s[i] == 'B'){
      b++;
    }else{
      c += b;
    }
  }
  printf("%lld\n", c);
  return 0;
}
//  [cpp]
#include <stdio.h>
#include <string.h>

char arr[1000000];

int main() {
    scanf("%s", arr);

    long long cb = 0, t = 0;
    for (char *p = arr; *p != '\0'; p++) {
        t += *p == 'W' ? cb : 0;
        cb += *p == 'B';
    }

    printf("%lld\n", t);
}
//  [cpp]
#include <iostream>

int main(void){
    int b = 0, ans = 0;
    std::string S;
    std::cin >> S;

    for (char c: S){
        if (c == 'B'){
            ++b;
        } else {
            ans += b;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;
 
int main(){
    string s;
    cin>>s;
    int n=s.size();
    int ans=0,tmp=0;
    rep(i,n){
        if(s[i]=='B') tmp++;
        else ans+=tmp;
    }    

    cout<<ans<<endl;
}
//  [cpp]
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000001;
const long long LINF = 1e18;
const int MAX = 510000;

int main() {
	int cnt = 0, ans = 0;
	string s;
	cin >> s;
		for(int i=0;i<s.size();i++){
			if (s[i] == 'W') {
				ans += i - cnt;
				cnt++;
		}
		}
		cout << ans << endl;
		return 0;

	}
//  [c]
#include <stdio.h>
#include <string.h>
typedef long long ll;

int len;
char str[200005];

int main()
{
    ll ans = 0;
    ll dist = 0;
        
    scanf("%s", str);
    len = strlen(str);

    for (int i = 0; i < len; i++) {
        if (str[i] == 'W') {
            ans += dist;
        }
        else {
            dist++;
        }
    }

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

    return 0;
}
//  [c]
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((int64_t *)a) < *((int64_t *)b) ? -1 : 1;
}

int compare_f2(const void *a, const void *b) {
	return *((uint64_t *)a) > *((uint64_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

static char S[200001];

int main(void) {
	scanf("%s", S);

	const size_t len = strlen(S);

    size_t wCount = 0;
    uint64_t sum = 0;
    for (size_t ofs = 0; ofs < len; ofs++) {
        if (S[len - ofs - 1] == 'W') {
            wCount++;
        }
        else {
            sum += (uint64_t)wCount;
        }
    }

    printf("%"PRIu64, sum);

	return 0;
}
//  [c]
#include <stdio.h>

int main(int argc, char *argv[])
{
    char S[(int)(2e5 + 1)];
    long long b = 0, ans = 0;
    char *s = S;

    gets(S);

    do {
        if (*s == 'B') b++;
        else ans += b;
    } while (*(++s));

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

    return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
int main(void){
  char cc[1000000]={};
  gets(cc);
  
  int wnum=0;
  long int sumpos=0;
  
  for(int i=0;i<strlen(cc);i++){
      if(cc[i]=='W'){
          wnum++;
          sumpos+=i;
      }
  }
  
  printf("%ld\n",sumpos-(wnum*(wnum-1))/2);
 
  return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
int main(void){
  char cc[1000000]={};
  gets(cc);
  
  int wnum=0;
  int sumpos=0;
  
  for(int i=0;i<strlen(cc);i++){
      if(cc[i]=='W'){
          wnum++;
          sumpos+=i;
      }
  }
  
  printf("%d\n",sumpos-(wnum*(wnum-1))/2);
 
  return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
int main(void){
  char cc[1000000];
  gets(cc);
  
  int wnum=0;
  int sumpos=0;
  
  for(int i=0;i<strlen(cc);i++){
      if(cc[i]=='W'){
          wnum++;
          sumpos+=i;
      }
  }
  
  printf("%d\n",sumpos-(wnum*(wnum-1))/2);
 
  return 0;
}
//  [javascript]
function main(input){
    lines = input;

    var count=0;
    var cou=0;
    var t = lines.length;
    for(var i=0;i<t;i++){
        var a=lines.charAt(i);
        if(a=="W"){
            count+=cou;
        }else{cou++;}
    }

    console.log(count);
}

main(require('fs').readFileSync('/dev/stdin','utf8'));
//  [javascript]
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.split(" ");
	//input = input.split("\n");
	//input = input.split(" ").map((a)=>Number(a));
	//input = input.split("\n").map((a)=>Number(a));
  var output = 0;
  var count = 0;
  for(var i = 0; i < input.length; i++){
    var tmp = input.slice(i,i+1);
    if(tmp == "B"){
       count++;
    }else{
      output += count;
    }
  }
  myout(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [javascript]
function Main(input) {
  input = input.split("\n");
  S= input[0].split("");
  var ans =0
  var n=0
  var w=0
  for(i=0;i<S.length;i++){
    if(S[i]=="W"){
      ans+=i-n;
      n++;
    }
  }
  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
   string s;cin>>s;
   int n = s.size();
   reverse(all(s));
   int cnt=0, res=0;
   rep(i,n){
       if(s[i]=='W')++cnt;
       else res+=cnt;
   }
   cout<<res<<endl;
}
//  [javascript]
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
S = inp.shift().split('')
cnt = 0
b = []
l = 0
for(i=0;i<S.length;i++) {
    if (S[i] == 'B') {
        b.push(i)
    } else {
        l = i
    }
}
for(i=0;i<b.length;i++) {
    cnt += l - b[i] - (b.length - i - 1)
}
console.log(cnt)
//  [javascript]
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
S = inp.shift().split('')
cnt = 0
i = 0
j = S.length - i 
b = 1
f = 0
while(i<j) {
    if (S[i]== 'B') {
        if (S[i+1] == 'W') {
            S[i] = 'W'
            S[i+1] = 'B'
            cnt++
        }
    } else {
        if (b) {
            f++
        }
    }
    i++
    if (i==j) {
        i = f
        j--
    }
}
console.log(i,j,cnt)
//  [go]
package main

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

func solution(s string) int {
        c := 0
        out := 0
        for i := 0; i < len(s); i++ {
                if s[i] == 'B' {
                        c++
                } else {
                        out += c
                }
        }
        return out
}

func main() {
        var fp *os.File = os.Stdin
        reader := bufio.NewReaderSize(fp, 1024)
        s := readLine(reader)
        fmt.Println(solution(s))
}

func readLine(reader *bufio.Reader) string {
        buf := make([]byte, 0, 1024)

        for {
                l, p, _ := reader.ReadLine()

                buf = append(buf, l...)

                if !p {
                        break
                }
        }
        return string(buf)
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 100000)

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	s := readLine()

	ans := int64(0)
	cnt := 0
	for i, ch := range s {
		if ch == 'W' {
			ans += int64(i - cnt)
			cnt++
		}
	}

	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func readLine() string {
	buf := make([]byte, 0, 100000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextI64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func anser(b bool, y string, n string) string {
	if b {
		return y
	}
	return n
}
//  [go]
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	s := nextMega()

	ans := 0
	for i, r := len(s)-1, len(s)-1; i >= 0 && r >= 0; i-- {
		if s[i] == 'B' {
			ans += r - i
			r--
		}
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(nil, 100000000)

	s := nextString()
	n := len(s)

	ss := make([]int, n)
	for i, v := range s {
		if v == 'B' {
			ss[i] = 1 // Black
		} else {
			ss[i] = 0 // White
		}
	}

	tmp := 0
	ans := 0
	for i := 0; i < n; i++ {

		if ss[i] == 1 {
			if tmp == -1 {
				tmp = i
			}
		} else {
			if tmp > -1 {
				l := ss[0:tmp]
				m := ss[tmp : i+1]

				r := make([]int, len(ss)-i-1)
				copy(r, ss[i+1:])

				m = append(m[len(m)-1:], m[:len(m)-1]...)

				ans += len(m) - 1
				i = i - (len(m) + 1)
				if i < 0 {
					i = 0
				}

				mid := append(m, r...)

				ss = append(l, mid...)
			}
			tmp = -1
		}
	}
	fmt.Println(ans)
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(nil, 100000000)

	s := nextString()
	n := len(s)

	ss := make([]int, n)
	for i, v := range s {
		if v == 'B' {
			ss[i] = 1 // Black
		} else {
			ss[i] = 0 // White
		}
	}

	tmp := 0
	ans := 0
	for i := 0; i < n; i++ {
		if tmp == 1 && ss[i] == 0 {
			ss[i-1] = 0
			ss[i] = 1
			if i > 1 {
				i -= 2
			}
			ans++
			tmp = 0
		}
		if ss[i] == 1 {
			tmp = 1
		} else {
			tmp = 0
		}
	}
	fmt.Println(ans)
}
//  [go]
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	//sc.Split(bufio.ScanWords)
	S := readLine()

	fmt.Printf("%d\n", AGC029A(S))
}

// AGC029A ...
func AGC029A(S string) int {
	res := 0

	tail := len(S) - 1
	for i := tail; i >= 0; i-- {
		if S[i] == 'W' {
			tail = i
			break
		}
	}

	for i := 0; i < len(S); i++ {
		if S[i] == 'B' {
			res += tail - i
			tail--
		}
	}

	return res
}
//  [ruby]
s = gets.chomp.bytes
w = 'W'.ord
ans = 0
wc = 0
s.size.pred.downto(0) do |i|
  if s[i] == w
    wc += 1
  else
    ans += wc
    wc -= 0
    wc = 0 if wc < 0
  end
end
puts ans
//  [ruby]
s = gets.chomp
count = tmp = 0

s.each_char do |c|
  c == 'W' ? count += tmp : tmp += 1
end

puts count
//  [ruby]
r=k=0;gets.chars{|c|c==?W?r+=k:k+=1};p r
//  [ruby]
s = gets.chomp.split("")
ookisa = s.size
i = 1
count = 0
until i == ookisa 
    if s[i] == "W" && s[i-1] == "B"
        s[i] = "B"
        s[i-1] = "W"
        count += 1
        if i >= 2
        i -= 1
        end
    else
        i += 1
    end
end
puts count
//  [ruby]
s = gets.chomp!.split("")
N = s.length
count = 0
left_w_count = 0
num_of_w = s.count("W")

loop do
  left_w_count = s.index("B")
  (left_w_count..N - 1).each do |i|
    # pp "DEBUG:i=#{i}"
    if s[i] == "B" and s[i + 1] == "W"
      s[i] = "W"
      s[i + 1] = "B"
      count += 1
      flag = 0
      #   pp "DEBUG:s=#{s}"
      break
    end
  end
  break if left_w_count == num_of_w
end

puts count
//  [ruby]
s = gets.chomp!.split("")
N = s.length
count = 0
loop do
  flag = 1
  (N - 1).times do |i|
    if s[i] == "B" and s[i + 1] == "W"
      s[i] = "W"
      s[i + 1] = "B"
      count += 1
      flag = 0
    end
  end
  break if flag == 1
end

puts count
//  [rust]
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let s: Vec<bool> = i
        .read_line()
        .as_bytes()
        .iter()
        .map(|&x| x == b'W')
        .collect();

    writeln!(o, "{}", solve(&s)).unwrap();
}
fn solve(s: &[bool]) -> usize {
    let mut result = 0;
    let mut blacks = 0;
    for &s in s {
        if s {
            result += blacks;
        } else {
            blacks += 1;
        }
    }
    result
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}
//  [rust]
#![allow(unused_imports)]

use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

fn main() {
    let s = input::<String>().chars().collect::<Vec<_>>();
    let mut w = 0;
    let mut ans = 0;
    for (i, c) in s.iter().enumerate() {
        if *c == 'W' {
            ans += i - w;
            w += 1;
        }
    }

    println!("{}", ans);
}

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

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}
//  [rust]
use std::io::stdin;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let s: Vec<char> = s.trim().chars().collect();

    let mut cum_cnt: usize = 0;
    let mut res: usize = 0;
    for s_i in s {
        if s_i == 'B' {
            cum_cnt += 1;
        } else if s_i == 'W' {
            res += cum_cnt;
        }
    }
    println!("{}", res);
}
//  [rust]
use proconio::input;

fn main() {
    input!(s: String);
    
    let mut b = s.len();
    let mut ans = 0;

    for i in (0..s.len()).rev() {
        if s.chars().nth(i).unwrap() == 'B' {
            ans += b - i - 1;
            b -= 1;
        }
    }

    println!("{}", ans);
}
//  [rust]
#[allow(dead_code)]

pub struct Scanner {
    idx: usize, 
    buf: Vec<String>,
}

impl Scanner {
    pub fn new<T: std::io::Read>(inf: &mut T) -> Scanner {
        Self {
            idx:0,
            buf: {
                let mut s = String::new();
                inf.read_to_string(&mut s).expect("I/O error");
                s.split_whitespace().map(|x| x.to_owned()).collect()
            },
        }
    }

    pub fn read<T: std::str::FromStr> (&mut self) -> T 
    where
        <T as std::str::FromStr>::Err: std::fmt::Debug,
    {
        if self.empty() {
            panic!("reached the end of input")
        }
        let ret = self.buf[self.idx].parse::<T>().expect("parse error");
        self.idx += 1;
        return ret;
    }

    pub fn empty(&self) -> bool {
        return self.idx >= self.buf.len();
    }
}

fn main() {
    let mut sc = Scanner::new(&mut std::io::stdin());
    let s: Vec<char> = sc.read::<String>().chars().collect();
    let n = s.len();
    let mut ans = 0;
    let mut cnt = 0;

    for i in 0..n {
        if s[i] == 'W' {
            ans += cnt;
        }
        else {
            cnt += 1;
        }
    }

    println!("{}", ans);
}
//  [rust]
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        mut s: Chars
    }
    let n = s.len();
    let mut ans = 0;

    let mut idx = 0;
    
    while idx < n-1 {
        let substr = s[idx..=idx+1].iter().collect::<String>();

        if &substr != "BW" {
            idx += 1;
            continue;
        }

        ans += 1;
        s[idx] = 'W';
        s[idx+1] = 'B';

        if idx != 0 {
            idx -= 1;
        }
    }

    println!("{}", ans);
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}
//  [swift]
var cnt=0;print(readLine()!.characters.reduce(0){$0+($1<"W" ? ++cnt*0:cnt)})
//  [swift]
import Foundation

var S = readLine()!
var ans = 0

while let range = S.rangeOfString("BW") {
    S = S.stringByReplacingCharactersInRange(range, withString: "WB")
    ans += 1
}

print(ans)
//  [typescript]
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ');
   let S = xs.toString();
   
   let count = 0;
   let ans = 0;
   
   for(let i=0; i<S.length; i++){
      if(S.charAt(i)=='B'){
      count++;
      //console.log(count);
      }else{
      ans += count;
       //console.log(ans); 
      }
   }
    console.log(ans);
 

}
Main(require('fs').readFileSync('/dev/stdin','utf8'));
//  [typescript]
s=require('fs').readFileSync('/dev/stdin','utf8').split('')
r = c = 0
for (i = 0; i < s.length; i++) {
	if(s[i] == 'W') {
		r += c
	} else {
		c++
	}
}
console.log(r)
//  [typescript]
import * as fs from "fs";

let S = fs.readFileSync("/dev/stdin", "utf8").trim();

// BWBWBW = 6
let position = S.length-1;
let answer = 0;
for(let i=S.length-1; i>=0; i--) {
    if (S[i] == 'B') {
        answer += position-i;
        position -= 1;
    }
}
console.log(answer);
//  [typescript]
s=require('fs').readFileSync('/dev/stdin','utf8').split('')
r = c = 0
for (i = 0; i < s.length; i++) {
	console.log(s[i])
	if(s[i] == 'W') {
		r += c
	} else {
		c++
	}
}
console.log(r
//  [typescript]
s=require('fs').readFileSync('/dev/stdin','utf8').split('')
r = c = 0
for (i = 0; i < s.length; i++) {
	if(s[i] == "W") {
		r += c
	} else {
		c++
	}
}
console.log(c)
//  [typescript]
s=require('fs').readFileSync('/dev/stdin','utf8').split('')
r = c = 0
l = s.length
for (i = 0; i < t; i++) {
	if(s[i] == "W") {
		r += c
	} else {
		c++
	}
}
console.log(c)
//  [python]
from sys import stdin
import math

N, D = stdin.readline().rstrip().split()

input_line = int(N)
dis = int(D)
cnt = 0

for i in range(input_line):
	s = stdin.readline().rstrip().split()
	X = int(s[0])
	Y = int(s[1])
	result = math.sqrt(X**2 + Y**2)

	# print(result)

	if result <= dis :
		cnt += 1

print(cnt)
//  [python]
from sys import stdin

N, D = stdin.readline().rstrip().split()
DD = int(D) ** 2
N = int(N)

CNT = 0

for i in range(N):
  X, Y = stdin.readline().rstrip().split()
  XX = int(X) ** 2
  YY = int(Y) ** 2
  ZZ = XX + YY
  if ZZ <= DD:
    CNT += 1
      
print(CNT)
//  [python]
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,D=MI()
    D2=D**2
    ans=0
    for i in range(N):
        x,y=MI()
        d2=(x**2+y**2)
        if d2 <= D2:
            ans+=1
            
    print(ans)
        

main()
//  [python]
import math

n, d = int(input().split())
count = 0

for i in range(n):
    xn, yn = int(input().split())
    if d >= math.sqrt(xn ** 2 + yn ** 2):
        count += 1

print(count)
//  [python]
N, D = map(int, input().split())

X = [0] * N
Y = [0] * N

for i in range(N):
    X[i], Y[i] = map(int, input.split())

count = 0

for i in range(N):
    if(D**2 >= X[i]**2 + Y[i]**2):
        count += 1

print(count)
//  [python]
n, d = map(int, input().split())
x = [list(map(int,input().split())) for i in range(n)]

ans = 0
for i,j in x:
    if (i**2)+(j**2)) <= d**2:
        ans += 1

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


public class Main{
  public static void main(String args[]){
  Scanner scanner = new Scanner(System.in);
   int n = scanner.nextInt();
   double d = scanner.nextInt();
   //System.out.println(d);
   int x[];
   int y[];
   int cnt = 0;
   x = new int[n];
   y = new int[n];
   double z = 0;
    for(int i=0;i<n;i++){
     x[i] = scanner.nextInt();
     y[i] = scanner.nextInt();
     z = (double)Math.sqrt(x[i]*x[i]+y[i]*y[i]);
  //System.out.println(z);
     //if(Math.sqrt(x[i]*x[i]+y[i]*y[i])<=d){
     if(z<=d){
          cnt++;
          //System.out.println(d + " " + z);
     }else{
     }
   }
  System.out.println(cnt);
  }
}
//  [java]
import java.util.Scanner;


public class Main{
  public static void main(String args[]){
  Scanner scanner = new Scanner(System.in);
   int n = scanner.nextInt();
   int d = scanner.nextInt();
   int x[];
   int y[];
   int cnt = 0;
   x = new int[n];
   y = new int[n];
   for(int i=0;i<n;i++){
     x[i] = scanner.nextInt();
     y[i] = scanner.nextInt();
     if(Math.sqrt(x[i]*x[i]+y[i]*y[i])<=d){
          cnt++;
     }else{
     }
   }
  System.out.println(cnt);
  }
}
//  [java]
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int n = sc.nextInt();
        int d = sc.nextInt();
        int ans = 0;

        for (int i = 0; i<n ; i++){
            float x = sc.nextFloat();
            float y = sc.nextFloat();

            double area = Math.sqrt( (x*x) + (y*y) );
            if (area<=d)
                ans++;
        }

        System.out.println(ans);
    }
}
//  [cpp]
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 10;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	if (*ci == '-') ci++;
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (72 - dig >> 3);
	return tmp;
}


int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	ll N = getint(), D = getint();
	D = D * D;

	int kotae = 0;
	rep(i, N) {
		ll X = getint(), Y = getint();
		kotae += (D >= X * X + Y * Y);
	}
	printf("%lld\n", kotae);


	Would you please return 0;
}
//  [cpp]
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<math.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;
int main()
{
int n,d,x,y,ans=0;
scanf("%d %d",&n,&d);
for(int i=0;i<n;i++)
{
 scanf("%d %d",&x,&y);
 if((x*x+y*y)<=d*d){ans++;}
}
printf("%d",ans);
}
//  [cpp]
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

int main()
{
	int n, d, x, y, ans = 0;
	cin >> n >> d;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		if (x * x + y * y <= d * d) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}
//  [cpp]
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<math.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;
int main()
{
int n,d,x,y,ans=0;
scanf("%d %d",&n,&d);
for(int i=0;i<n;i++)
{
 scanf("%d %d",&x,&y);
 if(x(*x+y*y)<=d*d){ans++;}
}
printf("%d",ans);
}