// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  var ans = "Yes";
  input = input.trim().split("\n");
  const [N, M] = input[0].split(" ").map((n) => parseInt(n));
  var a = input[1].split(" ").map((n) => parseInt(n));
  a.sort((a, b) => b - a);
  var top = a.slice(0, M);
  const lim = arrsum(a) / 4 / N;

  if (top[top.length - 1] < lim) {
    ans = "No";
  }

  function arrsum(arr) {
    return arr.reduce((c, a, i, self) => {
      return c + a;
    });
  }

  //出力
  console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require("fs").readFileSync("./input.txt", "utf-8"));


// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	var ans = 'Yes'
  input = input.trim().split("\n");
	const [N, M] = input[0].split(" ").map((n) => parseInt(n));
	var a = input[1].split(' ').map(n => parseInt(n))
	a.sort((a, b) => b - a)
	var top = a.slice(0, M)
	const lim = 4 * M

  if (top[top.length -1] < lim)	{
    ans = 'No'
  }

  //出力
  console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require("fs").readFileSync("./input.txt", "utf-8"));


// 参考: https://atcoder.jp/contests/abc161/submissions/12499845
// Kagemekaさんのおかげでfmt.Scan()でスライスを活用できることを知れました！

package main

import (
	"fmt"
)

func main() {
	var requires []int = make([]int, 2)
	for i := 0; i < 2; i++ {
		fmt.Scan(&requires[i])
	}

	var things []float64 = make([]float64, requires[0])
	var sumNum float64 = 0
	for i := 0; i < requires[0]; i++ {
		fmt.Scan(&things[i])
		sumNum += things[i]
	}

	var popularNum int = 0
	// なんか条件は小数点切り捨てじゃいけないらしい
	// 急がば回れ
	var requirement float64 = sumNum / float64(4*requires[1])
	for _, num := range things {
		if num >= requirement {
			popularNum++
		}
	}

	if popularNum >= requires[1] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


package main

import (
  "fmt"
  "sort"
)

func sumInt(a ...int) int {s := 0; for _, v := range a {s += v}; return s}

func main() {
  var n, m int
  fmt.Scan(&n, &m)
  a := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&a[i])
  }
  sort.Ints(a)
  s := sumInt(a...)
  ans := "No"
  if a[n-m] * 4*m >= s {
    ans = "Yes"
  }
  fmt.Println(ans)

}


package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main()  {
	var N, M int
	fmt.Scan(&N, &M)

	inputs := strings.Split(readLine(), " ")

	sum := 0

	for i := 0; i < N; i++{
		num, _ := strconv.Atoi(inputs[i])
		sum += num
	}

	count := 0
	MFloat := float32(M)

	for i := 0; i < N; i++ {
		num, _ := strconv.Atoi(inputs[i])
		numFloat := float32(num)

		if numFloat >= (float32(sum) / (4.0 * MFloat)){
			count = count + 1
		}
	}

	if count >= M {
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
}


//go:generate echo "https://atcoder.jp/contests/abc161/tasks/abc161_b"
package main

import (
	"bufio"
	"fmt"
	"io"
	"math/big"
	"os"
	"strconv"
)

var scan = newScanner(os.Stdin)

func Solve(As []int, M int) bool {
	sum := isum(As)
	c := 0
	for _, A := range As {
		if A >= sum/(4*M) {
			c++
		}
	}
	return c >= M
}

func main() {
	N, M := scan.Int(), scan.Int()
	As := scan.Ints(N)
	if Solve(As, M) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

type scanner struct {
	*bufio.Scanner
}

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) String() string {
	s.Scan()
	return s.Text()
}

func (s *scanner) Strings(l int) []string {
	if l == 0 {
		return []string{}
	}
	sl := make([]string, l, l)
	for i := range sl {
		sl[i] = s.String()
	}
	return sl
}

func (s *scanner) Int() int {
	n, _ := strconv.Atoi(s.String())
	return n
}

func (s *scanner) Ints(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func (s *scanner) Float64() float64 {
	f, _ := strconv.ParseFloat(s.String(), 64)
	return f
}

func (s *scanner) Floats64(l int) []float64 {
	if l == 0 {
		return []float64{}
	}
	sl := make([]float64, l, l)
	for i := range sl {
		sl[i] = s.Float64()
	}
	return sl
}

func (s *scanner) BigInt() *big.Int {
	n, _ := strconv.ParseInt(s.String(), 10, 64)
	return big.NewInt(n)
}

func (s *scanner) BigInts(l int) []*big.Int {
	if l == 0 {
		return []*big.Int{}
	}
	sl := make([]*big.Int, l, l)
	for i := range sl {
		sl[i] = s.BigInt()
	}
	return sl
}

func iabs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func imax(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func isum(X []int) int {
	sum := 0
	for _, x := range X {
		sum += x
	}
	return sum
}

func imin(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func ipow(x, n int) int {
	if n == 0 {
		return 1
	}
	a := ipow(x, n>>1)
	a *= a
	if n&1 != 0 {
		a *= x
	}
	return a
}

func chmax(x *int, v int) {
	if *x < v {
		*x = v
	}
}

func chmin(x *int, v int) {
	if *x > v {
		*x = v
	}
}

func factor(n int) map[int]int {
	m := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			n /= i
			m[i]++
		}
	}
	if n != 1 {
		m[n]++
	}
	return m
}

var mod = 1000000007

func setMintMod(x int) {
	mod = x
}

type mint int

func newMint(v int) mint {
	return mint((v%mod + mod) % mod)
}

func (x mint) Add(y mint) mint {
	v := x + y
	if v >= mint(mod) {
		return v - mint(mod)
	}
	return v
}

func (x mint) Sub(y mint) mint {
	v := x + mint(mod) - y
	if v >= mint(mod) {
		return v - mint(mod)
	}
	return v
}

func (x mint) Mul(y mint) mint {
	return (x * y) % mint(mod)
}

func (x mint) pow(n int) mint {
	if n == 0 {
		return mint(1)
	}
	a := x.pow(n >> 1)
	a = a.Mul(a)
	if n&1 != 0 {
		a = a.Mul(x)
	}
	return a
}

func (x mint) Inverse() mint {
	return x.pow(mod - 2)
}

func (x mint) Div(y mint) mint {
	return x * y.Inverse()
}

func (x mint) Neg() mint {
	return newMint(int(-x))
}

type factorial struct {
	fact        []mint
	factInverse []mint
}

func newFactorial(n int) *factorial {
	f := new(factorial)
	f.init(n)
	return f
}

func (f *factorial) init(n int) {
	fact := make([]mint, n+1, n+1)
	fact[0] = newMint(1)
	for i := 1; i <= n; i++ {
		fact[i] = fact[i-1].Mul(newMint(i))
	}

	inv := make([]mint, n+1, n+1)
	inv[n] = fact[n].Inverse()
	for i := n; i >= 1; i-- {
		inv[i-1] = inv[i].Mul(newMint(i))
	}

	f.fact = fact
	f.factInverse = inv
}

func (f *factorial) Get(n int) mint {
	return f.fact[n]
}

func (f *factorial) GetInverse(n int) mint {
	return f.factInverse[n]
}

func (f *factorial) Permutation(n, k int) mint {
	if k < 0 || n < k {
		return 0
	}
	return f.fact[n].Mul(f.factInverse[n-k])
}

func (f *factorial) Combination(n, k int) mint {
	if k < 0 || n < k {
		return 0
	}
	return f.fact[n].Mul(f.factInverse[k]).Mul(f.factInverse[n-k])
}

type sieve struct {
	n          int
	primes     []int
	maxFactors []int
}

func newSieve(n int) *sieve {
	s := &sieve{
		n:          n,
		primes:     []int{},
		maxFactors: make([]int, n+1, n+1),
	}
	s.init()
	return s
}

func (s *sieve) init() {
	s.maxFactors[0] = -1
	s.maxFactors[1] = -1
	for i := 2; i <= s.n; i++ {
		if s.maxFactors[i] != 0 {
			continue
		}
		s.primes = append(s.primes, i)
		s.maxFactors[i] = i
		for j := i * i; j <= s.n; j += i {
			if s.maxFactors[j] == 0 {
				s.maxFactors[j] = i
			}
		}
	}
}

func (s *sieve) IsPrime(x int) bool {
	return s.maxFactors[x] == x
}

func (s *sieve) Factor(x int) map[int]int {
	m := map[int]int{}
	for x != 1 {
		m[s.maxFactors[x]]++
		x /= s.maxFactors[x]
	}
	return m
}


package main

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

func main() {
	n, m := readI(), readI()
	a := readIs(n)

	sou := float64(sum(a))

	ninki := 0
	for _, v := range a {
		if float64(v) > sou/float64((4*m)) {
			ninki++
		}
	}

	if ninki >= m {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

func sum(a []int) int {
	b := 0
	for _, v := range a {
		b += v
	}
	return b
}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/hand_05.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

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

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

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

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


package main

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

func main() {
	n, m := readI(), readI()
	a := readIs(n)

	sou := sum(a)

	ninki := 0
	for _, v := range a {
		if v > sou/(4*m) {
			ninki++
		}
	}

	if ninki >= m {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

func sum(a []int) int {
	b := 0
	for _, v := range a {
		b += v
	}
	return b
}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/hand_05.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

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

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

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

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


n, m = gets.split.map(&:to_i)
values = gets.split.map(&:to_i)
total_v = values.inject(:+)
count = 0

values.each do |v|
  if v >= total_v.to_f / (4 * m)
    count += 1
  end
end

if count >= m
  puts 'Yes'
else
  puts 'No'
end


n, a = gets.chomp.split(" ").map(&:to_i)
k = gets.chomp.split(" ").map(&:to_i)
j = k.sort.reverse
all = 0
(1..n).each do |i|
    all += k[i-1]
end
count =0
N = (all.to_f / (4 * a.to_f)).ceil
(0..a-1).each do |d|
   count += 1 if j[d] >= N
end
puts count.to_i == a ? "Yes" : "No"


# Your code here!

n, a = gets.chomp.split(" ").map(&:to_i)
k = gets.chomp.split(" ").map(&:to_i)
j = k.sort.reverse
all = 0
(1..n).each do |i|
    all += k[i-1]
end
count =0
N = (all.to_f / (4 * a.to_f)).ceil

(0..a-1).each do |d|
    if j[d] >= N
        count += 1
    end
end
if a == count.to_i
    puts "Yes"
else
    puts "No"
end


n,m,*a=`dd`.split.map(&:to_i)
l=a.sum./4*m.to_f
c=a.inject(0){|a,b|b<l ? a : a+b}
puts c<m ? 'No':'Yes'


n,m,*a=`dd`.split.map(&:to_i)
puts a.inject(0){|a,b|b<a.sum./4*m.to_f ? a : a+b}<m ? 'No':'Yes'


n,m,*a=`dd`.split.map(&:to_i)
l=a.sum./4*m.to_f
c=a.inject(0){|a,b|a+b if b>=l}
puts c<m ? 'No':'Yes'


macro_rules! get_tuple {
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };

    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get_tuple!($($t),*)
        ).collect::<Vec<_>>()
    };
}

macro_rules! get_vec {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_| get_vec!($t)).collect::<Vec<_>>()
    };
}

fn main() {
    let (_, m) = get_tuple!(usize, usize);
    let v_a = get_vec!(usize);

    let sum: usize = v_a.iter().sum();
    let thresh = (sum as f64) / (4.0 * m as f64);
    let choosable = v_a.into_iter().filter(|&a| a as f64 >= thresh).count();
    let ans = if choosable >= m { "Yes" } else { "No" };
    println!("{}", ans)
}


// rust input macro: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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: i32, m: i32,
    a: [i32; n]
  };
  let mut sum: i32 = 0;
  for i in a.iter() {
    sum += *i;
  }
  let mut cnt = 0;
  for i in a.iter() {
    if i * 4 * m >= sum {
      cnt += 1;
    }
  }
  if cnt >= m {
    println!("Yes");
  }else{
    println!("No");
  }

}


use proconio::*;

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

    let sum: usize = a.iter().sum();
    let mut ans = 0;
    for i in 0..n {
        if a[i] >= (sum + 4 * m - 1) / (4 * m) {
            ans += 1;
        }
    }
    println!("{}", if ans >= m { "Yes" } else { "No" });
}


use proconio::{fastout, input, marker::*};

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

    a.sort();
    a.reverse();

    let sum = a.iter().sum::<usize>();

    if a[m-1] >= sum / (4 * m) {
        println!("Yes");
    } else {
        println!("No");
    }

}


use proconio::{fastout, input, marker::*};

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

    let total = a.iter().sum::<usize>() / (4 * m);

    println!(
        "{}",
        if m <= a.iter().filter(|&&x| total <= x).count() {
            "Yes"
        } else {
            "No"
        }
    );
}


use proconio::{fastout, input, marker::*};

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

    let total = (1f64 / (4f64 * m as f64) * a.iter().sum::<usize>() as f64) as usize;

    println!(
        "{}",
        if m <= a.iter().filter(|&&x| total <= x).count() {
            "Yes"
        } else {
            "No"
        }
    );
}


import Foundation

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

func main(){
    let nm = readInts()
    let (_,m) = (nm[0],nm[1])
    let votes = readInts().sorted { $0 > $1 }
    let total = votes.reduce(0) { $0 + $1 }
    let counter = votes.filter { $0*4*m >= total }.count

    print( counter >= m ? "Yes": "No")
}
main()


import Foundation

let inputLine = readLine()!.components(separatedBy: " ").map({Int($0)!})
let N = inputLine[0]
let M = inputLine[1]

let inputLine2 = readLine()!.components(separatedBy: " ").map({Int($0)!})

let sumVotes = inputLine2.reduce(0){$0 + $1}
let popularItems = inputLine2.filter({$0*4*M >= sumVotes})

if popularItems.count >= M {
    print("Yes")
} else {
    print("No")
}


// Popular Vote

func main() {
    let m = readLine()!.split(separator: " ").map{Int($0)!}[1]
    let a = readLine()!.split(separator: " ").map{Int($0)!}.sorted(by: >)

    let sum = a.reduce(0, +)

    if a[m-1] * 4 * m < sum {
        print("No")
    } else {
        print("Yes")
    }
}

main()


import Foundation

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

func main(){
    let nm = readInts()
    let (_,m) = (nm[0],nm[1])
    let votes = readInts().sorted { $0 > $1 }
    let total = votes.reduce(0) { $0 + $1 }
    let count = votes.filter { $0*4*m >= total }.count

    print( count >= 3 ? "Yes": "No")
}
main()


import Foundation

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

func main(){
    let nm = readInts()
    let (_,m) = (nm[0],nm[1])
    let votes = readInts().sorted { $0 > $1 }
    let total = votes.reduce(0) { $0 + $1 }
    let count = votes.filter { $0 < total / (4*m) }.count

    print( count >= 3 ? "Yes": "No")
}
main()


import Foundation

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

func main(){
    let nm = readInts()
    let (_,m) = (nm[0],nm[1])
    let votes = readInts().sorted { $0 > $1 }
    let total = votes.reduce(0) { $0 + $1 } // 総得票数

    for i in 0...m {
        if votes[i] * 4 * 2 < total {
            print("No")
            return
        }
    }
    print("Yes")
}

main()


import { isRegExp } from "util";

class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;

  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n:number):number[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n:number):string[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  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;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
  f(roop:number, callback:any){
    for(let i=0;i<roop;i++){
      callback(i);
    }
  };
  Yes(){
    console.log('Yes');
  }
  No(){
    console.log('No');
  }
  YES(){
    console.log('YES');
  }
  NO(){
    console.log('NO');
  }
}
const m = () => {
  const o = new AtCoder();
  let [n,m]=o.nn(2)
  let ar=[],g=0
  for(let i=0;i<n;i++){
    let t=o.n();
    g+=t;
    ar.push(t);
  }
  let bo = g/(4*m)
  o.asc(ar);
  for(let i=0;i<m;i++){
    if(Number(ar.pop()) < bo){
      o.No()
      return
    };
  }
  o.Yes()
}
m();


function main(input) {
  const lines = input.split("\n");
  const [N, M] = lines[0].split(' ').map(Number);
  const a = lines[1].split(' ').map(Number);

  const total = a.reduce((acc, current) => acc + current);
  const border = total / (4 * M);
  let count = 0;
  a.forEach(n => {
    if (n < border) return;
    count++;
  });

  console.log(count < M ? 'No' : 'Yes');
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(input: string) {
  const params: string[][] =
    input.split('\n')
      .map(line => line.split(' '));
  const [n, m] = params[0].map(x => parseInt(x));
  const a: number[] = params[1].map(x => parseInt(x));

  const sum = a.reduce((x, y) => x + y);

  const b = a.filter(x => 4 * m * x >= sum);

  const msg = (b.length >= m) ? 'Yes' : 'No';

  console.log(msg)
}

const fs = require('fs');
const input = fs.readFileSync('/dev/stdin', 'utf8');
Main(input);


process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const itemNum = Number(inputs[0].split(' ')[0]);
  const selectNum = Number(inputs[0].split(' ')[1]);
  const itemList = inputs[1].split(' ')
                   .map(Number)
                   .sort((x, y) => (x < 1 ? 1 : -1));
  const totalVotes = itemList.reduce((acc, cur) => acc + cur);

  if (itemList[selectNum - 1] * 4 < totalVotes) {
    console.log('No');
  } else {
    console.log('Yes');
  }
}


function Main(input: string) {
  const lines = input.split('\n');
  const params1 = lines[0].split(' ').map(x => parseInt(x));
  const params2 = lines[1].split(' ').map(x => parseInt(x));

  const n = params1[0];
  const m = params1[1];
  const a = params2;

  const sum = a.reduce((m, n) => m + n);

  const b = a.filter(x => 4 * x >= sum);

  const msg = (b.length >= m) ? 'Yes' : 'No';

  console.log(msg)
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function Main(input: string) {
  const lines = input.split('\n');
  const params1 = lines[0].split(' ').map(x => parseInt(x));
  const params2 = lines[1].split(' ').map(x => parseInt(x));

  const n = params1[0];
  const m = params1[1];
  const a = params2;

  const sum = a.reduce((m, n) => m + n);
  const pickSum = sort(a).slice(0, m).reduce((m, n) => m + n);

  const msg = (sum <= 4 * pickSum) ? 'Yes' : 'No';

  console.log(msg)
}

function sort(a: number[]): number[] {
  let b = a;
  b.sort((m, n) => n - m);
  return b
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


n=int(input())
dict1={}
flag=0
arr=[]
for i in range(n):
    s=str(input())
    if(i==0):
        dict1[s]=1
        arr.append(s)
    else:
        if(arr[-1][-1]!=s[0]):
            flag=1
        else:
            try:
                dict1[s]+=1
                flag=1
            except:
                KeyError
                dict1[s]=1
            arr.append(s)
if(flag==0):
    print("Yes")
else:
    print('No')


N = int(input())
W = [input() for i in range(N)]

result = True

for i in range(1, N):
    if W[i-1][-1] != W[i][0]:
        result = False
        break
    if W[i] in W[:i]:
        result = False
        break

if result:
    print("Yes")
else:
    print("No")


N = int(input())
w =[input() for i in range(N)]

ans = "Yes"
if len(set(w))!=len(w):
    ans = "No"
for i in range(N-1):
    if w[i+1][0] !=w[i][-1]:
        ans = "No"
        break
print(ans)


import sys
import numpy as np
import collections as cl
import itertools as it
# import more_itertools as mit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(100000)

n = int(readline())
w = list(readlines().split())
dic = set()

for i in w:
    if i == 0:
        dic.append(i)
        continue
    if i in dic or dic[i-1][-1] != dic[i][0]:
        print('No')
        sys.exit()
    dic.append(i)
print('Yes')


n = int(input())
list_w = [input() for s in range(0, n)]
for i in range(0, n):
    if i == 0 or (list_w[i - 1][-1] == list_w[i][0]) and list_w[i] not in list_w[:i]:
        print(list_w[i])
        continue
    else:
        print("No")
        exit()
print("Yes")


n = int(input())
list_w = [input() for s in range(0, n)]
for i in range(0, n):
    if i == 0 or (list_w[i][-1] == list_w[i][0] and list_w[i] not in list_w[:i]):
        continue
    else:
        print("No")
        exit()
print("Yes")


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;

    int in_N;

    int                     cnt;
    HashMap<String, String> word;
    String                  last;
    boolean                 ans;

    try
    {
      in_stream = new BufferedReader(new InputStreamReader(System.in));
      word      = new HashMap<String, String>();

      /*----------------
       * 引数
       *----------------*/
      in_str = new String(in_stream.readLine());
      in_N   = Integer.parseInt(in_str);

      ans    = true;
      last = new String(in_stream.readLine());
      word.put(last, "a");
      for(cnt=1; cnt<in_N; cnt++)
      {
        in_str = new String(in_stream.readLine());

        if(null == word.get(in_str))
        {
          if( !(last.substring(last.length()-1, last.length()).equals(in_str.substring(0, 1))) )
          {
            ans = false;
            break;
          }

          last = in_str;
          word.put(last, "a");
        }
        else
        {
          ans = false;
          break;
        }
      }

      /*----------------
       * 計算
       *----------------*/
      if(ans)
      {
        System.out.println("Yes");
      }
      else
      {
        System.out.println("No");
      }
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}


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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N=nextInt();

		String ans ="Yes";
		String last=nextString();
		Map<String,Boolean> map = new HashMap<>();
		map.put(last, true);
		for(int i=1;i<N;i++){
			String w = nextString();
			if(last.charAt(last.length()-1)==w.charAt(0)&&!map.containsKey(w)){
				last=w;
				map.put(last, true);
			}else{
				ans="No";
				break;
			}
		}

		System.out.println(ans);

	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}


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

public class Main{
	public static void main(String[] args){
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			ArrayList<String> list = new ArrayList<String>();
			int N =Integer.parseInt(br.readLine());
			String pre = br.readLine();
			list.add(pre);
			for(int i=1;i<N;i++){
				String post = br.readLine();
				if(list.contains(post)){
					System.out.println("No");
					return;
				}
				if(pre.charAt(pre.length()-1) != post.charAt(0)){
					System.out.println("No");
                                        return;
				}
				list.add(post);
				pre = post;
			}
			System.out.println("Yes");
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try {
				br.close();
			} catch (IOException e) {
				// NOP
			}
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        final Set<String> seen = new HashSet<>();
        char prev = '#';
        for (int i = 0; i < n; i++) {
            final String curr = fs.next();
            if (!seen.add(curr) || (prev != '#' && curr.charAt(0) != prev)) {
                System.out.println("No");
                break;
            }
            prev = curr.charAt(curr.length() - 1);
        }
        System.out.println("Yes");
    }

    static final class Util {
        public static void shuffleSort(int[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffleSort(long[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(int[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void shuffle(long[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(int[] x, int i, int j) {
            final int t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        public static void swap(long[] x, int i, int j) {
            final long t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        private Util() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


import java.util.*;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	String ans = "Yes";
		String[] w = new String[n];
		for(int i=0; i<w.length; ++i){
			w[i] = scn.next();
		}
      	String[] ww = new String[n];
      	for(int i=0; i<w.length; ++i){
			ww[i] = w[i];
		}
      	Arrays.sort(ww);
      	for(int i=1; i<w.length; ++i){
			if(ww[i].equals(ww[i-1])){
              ans = "No";
            }
		}
      	for(int i=1; i<w.length; ++i){
          char[] last = list[i-1].toCharArray();
          char[] first = list[i].toCharArray();
          if(last[last.length-1] != first[0]){
            ans = "No";
          }
        }
      	System.out.println(ans);
	}
}


import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        String[] s = new String[n];
        for(int i = 0; i<n; i++){
            s[i] = in.next();
        }
        String prev = s[0];
        boolean check = true;
        for(int i = 1; i<n; i++){
            if(s[i].charAt(0)!=prev.charAt(prev.length()-1)){
                check = false;
                out.println("No");
                break;
            }
            prev = s[i];
        }
        if(check) out.println("Yes");
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}


#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
using namespace std;
int a = 0, b = 0, c = 0, d = 0, e[60][60], f[100200], g[100200], h[100200], counto = 1000000000, ans =1 , x[100] = {}, y, z;
int64_t ab[10000] = {}, abc = 0, abcd = 0;
pair<int, int>manji[101] = {};
char rikka, toka[150][150] = {};
vector<int> train, code;
vector<char>aka, ao;
string saya, homu, kyok, mami[108], mado[100];
bool gg = true ,ap=false;
bool exist[100200];
int main() {
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> mami[i];
		if ( i != 0) {
			if (mami[i].substr(0, 1) != mami[i - 1].substr(mami[i - 1].length() - 1) ) {
				//cout << mami[i - 1].substr(mami[i - 1].length()-1) << endl;
				//cout << mami[i].substr(0,1) << endl;
				cout << "No" << endl;
				return 0;
			}
			//cout << '1' << endl;
		}
		/*if (mami[i].length() == 1) {
			mami
		}*/
		for (int j = 0; j < i; j++) {
			if (mami[j] == mami[i]) {
				cout << "No" << endl;
				return 0;
			}
		}
		//cout <<'2'<< endl;
	}
	cout << "Yes" << endl;

	return 0;
}


#include<iostream>
#include<string>
using namespace std;

string arr[100];

int main(){
	int n;
	cin >> n;
	bool check = 1;
	cin >> arr[0];
//	cout << arr[0] << endl;
	for(int i = 1; i < n; i++){
		cin >> arr[i];
		if(arr[i][0] != arr[i-1][arr[i-1].length()-1]){
//			cout << arr[i][0] << " " << arr[i-1][arr[i-1].length()-1] << endl;
			check = 0;
		}
	}
	for(int i = 0; i < n-1; i++){
		for(int j = i+1; j < n; j++){
			if(arr[i].compare(arr[j]) == 0)
				check = 0;
		}
	}
//	cout << check << endl;
	if(check)
		cout << "Yes\n";
	else
		cout << "No\n";
}


#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

bool solve(){
  int n;
  cin>>n;
  vector<string> v(n);
  rep(i,n) cin>>v[i];

  rep(i,1,n){
    rep(j,i) if(v[j]==v[i]) return false;
    if(v[i-1].back() != v[i][0]) return false;
  }

  return true;
}

int main(){
  cout << (solve() ? "Yes" : "No") << endl;
  return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<string> a(n);
    set<string> s;
    rep(i,n) {
        string w;
        cin >> w;
        if (s.count(w)) {
            cout << "No" << endl;
            return 0;
        }
        s.insert(w);
        a.push_back(w);
    }
    for (int i = 0; i <= n-2; i++) {
        if (a[i].back() != a[i+1][0]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N;
  cin >> N;
  vector<string> vec(N);
  int S;
  int ans = 0;
  char C = 'X';
  rep(i, N) {
    cin >> vec.at(i);
    if(vec.at(i).at(0) != C) {
      ans++;
    }
    S = vec.at(i).size();
    C = vec.at(i).at(S-1);
    rep(j, i) {
      if(vec.at(i) == vec.at(j)) {
        ans++;
        break;
      }
    }
    if(ans > 0) {
      break;
    }
    if(i == N - 1) {
      break;
    }
  }
  if(ans > 0) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N;
  cin >> N;
  vector<string> vec(N);
  int S;
  int ans = 0;
  char C = 'X';
  rep(i, N) {
    cin >> vec.at(i);
    if(vec.at(i).at(0) == C) {
      ans++;
    }
    S = vec.at(i).size();
    C = vec.at(i).at(S-1);
    rep(j, i) {
      if(vec.at(i) == vec.at(j)) {
        ans++;
        break;
      }
    }
    if(ans > 0) {
      break;
    }
    if(i == N - 1) {
      break;
    }
  }
  if(ans > 0) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    char w[1000][1000];
    int n, flag=0, l, i, j;

    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%s",w[i]);

    for(i=0;i<n;i++){
        for(j=1;j<n;j++){
            if(strcmp(w[i],w[i+j])==0) flag=1;
        }
        if(i>0){
            l=strlen(w[i-1]);
            if(w[i-1][l-1]!=w[i][0]) flag=1;
        }
    }
    if(!flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}


#include<stdio.h>
#include<string.h>
int main(void){
	int n,i,j,a=1;
	scanf("%d",&n);
	char w[99][11];
	for(i=0;i<n;i++){
		scanf("%s",w[i]);
		if(i>0&&a!=0){
			if(w[i][0]!=w[i-1][strlen(w[i-1])-1]){a=0;}
			for(j=0;j<i;j++){
				if(strcmp(w[j],w[i])==0){a=0;}
			}
		}
	}
	printf(a?"Yes":"No");
	return 0;
}


#include <stdio.h>
#include <string.h>
int main(){
  int n;  scanf("%d", &n);
  char siri[103][13];
  int flag = 0;
  for(int i=0; i<n; i++){
    scanf("%s", siri[i]);
    for(int j=0; j<i; j++)
      if(strcmp(siri[i], siri[j])==0){
	flag = 1;
	break;
      }
    if(flag || (i>0 && siri[i][0]!=siri[i-1][strlen(siri[i-1])-1])){
	flag = 1;
	break;
    }
  }
  if(flag)
    printf("No\n");
  else
    printf("Yes\n");
  return 0;
}


#include <stdio.h>
#include <string.h>

int main(){
    char A[11],B[11],C[11];
    scanf("%s %s %s", &A,&B,&C);
    int lenA=strlen(A);
    int lenB=strlen(B);

    if(A[lenA-1]==B[0] && B[lenB-1] == C[0]){
        printf("YES");
    }
    else {
        printf("NO");
    }

    return 0;
}


#include<stdio.h>
#include<string.h>

int main() {
  int n, k=0;
  scanf("%d", &n);
  char str[n][11];
  for(int i = 0; i < n; i++) {
    scanf("%s", &str[i]);
  }

  for(int i = 0; i < n-1; i++) {
    for(int j = i+1; j < n; j++) {
      printf("str[%d] = %s, str[%d] = %s\n", i, str[i], j, str[j]);
      if(strcmp(str[i], str[j]) == 0) {
        k++;
      }
      if(str[i][strlen(str[i])-1] != str[i+1][0]) {
        k++;
      }
    }
  }
  if(k >= 1) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }
  return ;
}


#include<stdio.h>
#include<string.h>

int main() {
  int n, k=0;
  scanf("%d", &n);
  char str[n][11];
  for(int i = 0; i < n; i++) {
    scanf("%s", &str[i]);
  }

  for(int i = 0; i < n-1; i++) {
    for(int j = i+1; j < n; j++) {
      printf("str[%d] = %s, str[%d] = %s\n", i, str[i], j, str[j]);
      if(strcmp(str[i], str[j]) == 0) {
        k++;
      }
      if(str[j-1][strlen(str[j-1])-1] != str[j][0] && i != j) {
        k++;
      }
    }
  }
  if(k >= 1) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }
  return ;
}


function Main(input){
    input = input.split("\n")
    var N = parseInt(input[0],10)
    input.shift()
    var W = input

    for(var i = 0;i < N;i++){
        for(var j = i + 1;j < N;j++){
            if(W[i] === W[j]){
                console.log("No")
                return
            }
        }
    }

    for(var i = 0;i < N - 1;i++){
        if(W[i].slice(-1) !== W[i+1].slice(0,1)){
            console.log("No")
            return
        }
    }

    console.log("Yes")
}

Main(require("fs").readFileSync("/dev/stdin","utf8"))


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 list = [];
  for(var i = 1; i < input.length; i++){
    if(i == 1){
       list.push(input[i]);
       }else{
       	if(list.indexOf(input[i]) == -1){
           var tmp = list[list.length - 1].split("");
          tmp = tmp[tmp.length - 1];
          var tmp2 = input[i].slice(0,1);
          //myout(tmp2);
          if(tmp == tmp2){
             list.push(input[i]);
             }else{
               myout("No");
            return;
             }
          }else{
           myout("No");
            return;
          }
       }
  }
  myout("Yes");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


function main(input) {
  var N = input[0]-0;
  var ans = "Yes";
  var map = {};
  var next = "";
  for(var i=1;i<=N;i++){
    var str = input[i];
    if(map[str]){
      ans = "No";
      break;
    }else{
      if(next!=""){
        if(str[0] != next){
          ans = "No";
          break;
        }
      }
      next = str[str.length-1];
      map[str] = true;
    }
  }
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


function main(input) {
  const args = input.split('\n');
  const N = parseInt(args[0], 10);
  let words = [];
  let ans = 'Yes';
  let pre_w;

  for (let i = 1; i < args.length; i++) {
    last_w = args[i].slice(args[i].length - 1);
    first_w = args[i].slice(0, 1);
    //初回
    if (!pre_w) {
      words.push(args[i]);
      pre_w = last_w;
    } else {
    //２回目以降
      if (pre_w === first_w) {
        if (!words.includes(args[i])) {
          words.push(args[i]);
          pre_w = last_w;
        } else {
          ans = 'No';
          break;
        }
      } else {
        ans = 'No';
        break;
      }
    }
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main(input) {
  const args = input.split('\n');
  const N = parseInt(args[0], 10);
  let words = [];
  let ans = 'Yes';
  let pre_w;

  for (let i = 1; i < args.length; i++) {
    last_w = args[i].slice(args[i].length - 1);
    first_w = args[i].slice(0, 1);

    if (!pre_w) {
      words.push(args[i]);
      pre_w = last_w;
      isFirst = false;
    } else {
      if (pre_w === first_w) {
        if (!words.includes(args[i])) {
          words.push(args[i]);
          pre_w = last_w;
        } else {
          ans = 'No';
          break;
        }
      } else {
        ans = 'No';
        break;
      }
    }
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


/*
-------関数一覧--------
arr1dto2d(Array) 一次元配列を二次元配列にします
pf(N)因数分解した結果をオブジェクトで返します
gcd(a,b)最大公約数を返します
lcm(a,b)最小公倍数を返します
num(a,b)a-bを返します。ソート用です
isPrime(n)素数かどうか真偽値で返します
isNumber(n)数かどうか真偽値で返します
arrsum(arr)配列の合計値を返します
nibu(arr,n)n以下で最も大きい数の添字を返します(nを含みます)
br(input)入力を改行で区切ります
*/
const debugMode = false;
const inf = Number.MAX_SAFE_INTEGER;

function Main(input){
    input = input.split("\n");
    var flag = true;
    input.shift();
    var arr = {};
    input.forEach(function(val){
        if(arr[val]){
            flag = false;
        }else{
            arr[val] = 1;
        }
    })
    input = arr1dto2d(input);
    for(var i=1;i<input.length;i++){
        console.log(input[i])
        if(input[i-1][input[i-1].length-1]!=input[i][0]){
            flag = false;
            break;
        }
    }
    console.log(flag?"Yes":"No")
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function next(m,now){

}
function zisyozyunn(a){
  var arr = [];
  for(var i=0;i<input[0];i++){
    arr.push(i+1);
  }
  var sum = 0;
  for(i=0;i<a.length;i++){
    var f = arr.findIndex(val => val==a[i]);
    sum += factorialize(a.length-1-i)*f;
    arr.splice(f,1);
  }
  return sum;
}
function arrsum(arr){
  var sum = 0;
  for (var i=0,len=arr.length; i<len; ++i) {
      sum += arr[i]-0;
  };
  return sum;
}
function debug(val){
  if(debugMode==true){
    console.log(val)
  }
}
function arrMaxPoint(arr){
	var max = Number.MIN_SAFE_INTEGER;
	var point = -1;
	for(var i=0;i<arr.length;i++){
		if(max<arr[i]){
			max = arr[i];
			point = i;
		}
	}
	return point;
}
function arrMinPoint(arr){
	var min = Number.MAX_SAFE_INTEGER;
	var point = -1;
	for(var i=0;i<arr.length;i++){
		if(min>arr[i]){
			min = arr[i];
			point = i;
		}
	}
	return point;
}
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
		arr[i]=arr[i].split("");
		}
	return arr;
}
function isPrime(n){
    if(false===Number.isInteger(n)){
        return false;
    }
    if(n<=1){
        return false;
    }
    if(2===n){
        return true;
    }
    if(0===n%2){
        return false;
    }
    var square_root = Math.floor(Math.sqrt(n));
    for(var i=3; i<=square_root; i+=2){
        if(0===n%i){
            return false;
        }
    }
    return true;
}
function isNumber(val){
	const pat = /^([1-9]\d*|0)$/;
	return pat.test(val);
}
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
		arr[i]=arr[i].split("");
		}
	return arr;
}
function factorialize(num) {
  if (num === 0) { return 1; }
  return num * factorialize(num-1);
}
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
    arr[i]=arr[i].split("");
    }
  return arr;
}
function rotate(array) {
  const ROW = array.length;
  const COL = array[0].length;
  const row = ROW-1;
  var a = new Array(COL);
  for (var c=0; c<COL; c++) {
    a[c] = new Array(ROW);
    for (var r=0; r<ROW; r++) {
      a[c][r] = array[row-r][c];
    }
  }
  return a;
}
function part_in(base,push,st){
	for(var i=st,p=0;p<push.length;i++,p++){
		base[i] = push[p];
	}
	return base;
}
function part_reverse(arr,s,g){
	var push = arr.slice(s-1,g);
  push.reverse();
	arr = part_in(arr,push,s-1);
	return arr;
}
function zeroPadding(num,length){
    return (num + '000000000000000000000000000000000').slice(0,length);
}
function arrsum(arr){
    var sum = 0;
    for (var i=0,len=arr.length; i<len; ++i) {
        sum += arr[i]-0;
    };
    return sum;
}
function pf(n) {
    var result = {};

    if (n === 1) {
        return {"1":1}
    }

    var init = 2;

    while (n !== 1) {
        var i = init;
        while (i < Number.MAX_SAFE_INTEGER) {
            if (n % i === 0) {
                n /= i;
                if (!(result[i] > 0)) {
                    result[i] = 0;
                }
                result[i]++;
                break;
            }
            i++;
        }
        init = i;
    }
    return result;
}
function gcd(a, b) {
    if (b === 0){
        return a
    }
    return gcd(b, a % b)
}
function lcm(a,b) {
    var g = (n, m) => m ? g(m, n % m) : n
    return a * b / g(a, b)
}
function num(a, b) {
  return a - b;
}
function nibu(a,searchValue){
	var index = -1;

//調べる左端を表す添字(index)
var left = 0;

//調べる右端を表す添字(index)
var right = a.length-1;

//左端と右端にデータがある間は処理を繰り返す
while(left <= right){

    //左右の真ん中を表す添字(index)
    middle =Math.floor((left +right)/2);

    //真ん中の値と探す値を比較する
    if(a[middle]==searchValue){
        //一致した場合、変数に入れて処理終了
        index = middle;
        break;
    }else if(a[middle]<searchValue){
        //探す値より小さい場合、左側にはもっと小さい値しかないので左端の値を真ん中の値の右に移動する
        left = middle +1;
    }else{
        //探す値より大きい場合、右側にはもっと大きい値しかないので右端の値を真ん中の値の左に移動する
        right = middle -1;
    }
}
if(index!=-1) return index;
else return left;
}
function br(input){
  return input.split("\n");
}
function is_sortred(arr){
  var flag = true;
  for(var i=1;i<arr.length;i++){
    if(arr[i-1]>arr[i]){
      flag = false;
      break;
    }
  }
  return flag;
}


package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func scanStrings(n int) []string {
	sl := make([]string, n)
	for i := range sl {
		sl[i] = scanString()
	}
	return sl
}

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

func main() {
	n := scanInt()
	w := scanStrings(n)

	m := map[string]bool{}
	lc := w[0][0]
	for _, s := range w {
		if m[s] || s[0] != lc {
			fmt.Println("No")
			return
		}

		lc = s[len(s)-1]
		m[s] = true
	}

	fmt.Println("Yes")
}


package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

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

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

	return b
}

func main() {
	n := nextInt()
	w := make([]string, n)

	for i := 0; i < n; i++ {
		w[i] = next()
	}

	already := map[string]bool{}
	already[w[0]] = true
	for i := 1; i < n; i++ {
		prev := w[i-1]
		s := w[i]
		if already[s] || prev[len(prev)-1] != s[0] {
			fmt.Println("No")
			return
		}
		already[s] = true
	}

	fmt.Println("Yes")
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"reflect"
	"strconv"
	"strings"
	// "regexp"
)

type i64 int64
type pair struct {
	p1, p2 interface{}
}

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
)

func main() {
	buf := make([]byte, initialBufSize)
	scanner.Buffer(buf, maxBufSize)
	scanner.Split(bufio.ScanWords)
	N := readInt()
	var n []string
	for i := int64(0); i < N; i++ {
		n = append(n, readString())
	}

	isrule := true
	// 直前の文字
	prevc := ""
	// 末尾一致 確認
	for i := int64(0); i < N; i++ {
		p := string(n[i][len(n[i])-1])
		if i == 0 {
			prevc = p
		} else {
			if prevc != string(n[i][0]) {
				isrule = false
				break
			}
			prevc = p
		}
	}
	// 同じ文字確認
	m := map[string]int{}
	for i := int64(0); i < N; i++ {
		_, ok := m[string(n[i])]
		if ok {
			isrule = false
			break
		}
		m[string(n[i])]++
	}

	if isrule {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

/*==========================================
 *             Library
 *==========================================*/

func aryEq(a []int64, b []int64) bool {
	return reflect.DeepEqual(a, b)
}

func clone(n []int64) (r []int64) {
	r = make([]int64, len(n))
	for i := 0; i < len(n); i++ {
		r[i] = n[i]
	}
	return
}
func write(s string) {
	writer.WriteString(s)
}

func print() {
	writer.Flush()
}

// scanner.Split(bufio.ScanWords) をコメントアウトしないと使用不可
func readLine() (s string) {
	if scanner.Scan() {
		s = scanner.Text()
	}
	return s
}

func readInt() (read int64) {
	scanner.Scan()
	read, err := strconv.ParseInt(scanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return
}

func readFloat() (read float64) {
	scanner.Scan()
	read, err := strconv.ParseFloat(scanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return
}

func readRunes() (read []rune) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, v)
	}
	return
}

func readString() (read string) {
	scanner.Scan()
	read = scanner.Text()
	return
}

func readStrings() (read []string) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, string(v))
	}
	return
}

func s2i(s string) int64 {
	var intVal, e = strconv.ParseInt(s, 10, 64)
	if e != nil {
		panic(e)
	}
	return intVal
}

func i2s(i int64) string {
	var strVal = strconv.FormatInt(i, 10)
	return strVal
}

func s2f(s string) float64 {
	var floatVal, e = strconv.ParseFloat(s, 64)
	if e != nil {
		panic(e)
	}
	return floatVal
}

func abs(i int64) int64 {
	return int64(math.Abs(float64(i)))
}

func sum(i []int64) int64 {
	sum := int64(0)
	for _, val := range i {
		sum += val
	}
	return sum
}

func split(s string) []string {
	return strings.Fields(s)
}

func strAry2intAry(strs []string) []int64 {
	var ret = make([]int64, 0, len(strs))
	for _, str := range strs {
		var intVal = s2i(str)
		ret = append(ret, intVal)
	}
	return ret
}

func intAry2strAry(nums []int64) []string {
	var ret = make([]string, 0, len(nums))
	for _, num := range nums {
		var strVal = i2s(num)
		ret = append(ret, strVal)
	}
	return ret
}

func ary2str(strs []string) string {
	return strings.Join(strs, " ")
}

func reverse(res []int64) []int64 {
	for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
		res[i], res[j] = res[j], res[i]
	}
	return res
}
func reverseStr(res []string) []string {
	for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
		res[i], res[j] = res[j], res[i]
	}
	return res
}

func ini(res []int, init int) {
	if len(res) == 0 {
		return
	}
	res[0] = init
	for i := 0; i < len(res); i++ {
		copy(res[i:], res[:i])
	}
}

//
// func regexpExample() {
//     // Your code here!
//     var str = "13:20"
//     r := regexp.MustCompile(`(\d+):(\d+)`)
//     fmt.Println(r.FindStringSubmatch(str))
// }

// type Country struct {
//     gold int
//     silver int
//     blonze int
// }

// // 複数ソートのサンプル
// func stableSortExample() []Country{
//     var country = []Country {
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:3, blonze:2},
//         {gold:1, silver:3, blonze:3},
//     }
//     sort.SliceStable(country, func(i, j int) bool { return country[i].blonze > country[j].blonze })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].silver > country[j].silver })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].gold > country[j].gold })
//     return country
// }


package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%v", &N)

	words := make([]string, 0, N)

	for i := 0; i < N; i++ {
		var s string
		fmt.Scanf("%s", &s)
		words = append(words, s)
	}

	tail := string(words[0][0])
	already := make(map[string]bool)
	for _, w := range words {
		if _, exist := already[w]; exist {
			fmt.Println("No")
			return
		}
		if tail != string(w[0]) {
			fmt.Println("No")
			return
		}
		tail = string(w[len(w)-1])
	}

	fmt.Println("Yes")
	return
}


package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%v", &N)

	words := make([]string, 0, N)

	for i := 0; i < N; i++ {
		var s string
		fmt.Scanf("%s", &s)
		words = append(words, s)
	}

	tail := string(words[0][0])
	already := make(map[string]bool{})
	for _, w := range words {
		if _, exist := already[w]; exist {
			fmt.Println("No")
			return
		}
		if tail != string(w[0]) {
			fmt.Println("No")
			return
		}
		tail = string(w[len(w)-1])
	}

	fmt.Println("Yes")
	return
}


package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%v", &N)

	words := make([]string, 0, N)

	for i := 0; i < N; i++ {
		var s string
		fmt.Scanf("%s", &s)
		words = append(words, s)
	}

	tail := string(words[0][0])
	for _, w := range words {
		if tail != string(w[0]) {
			fmt.Println("No")
		}
		tail = string(w[len(w)-1])
	}

	fmt.Println("Yes")
}


N = gets.chomp.to_i

flag = true

h = Hash.new(false)
w = []
N.times do |i|
  w << gets.chomp

  if h[w[i]]
    flag = false
  end

  h[w[i]] = true

  next if i == 0

  if w[i-1][-1] != w[i][0]
    flag = false
  end
end

puts flag ? 'Yes' : 'No'


N = gets.to_i
w = gets.chomp
A = []
A.push w
(N-1).times do |i|
    s = gets.chomp
    if w[-1] != s[0] || A.include?(s) then
        puts "No"
        exit
    else
        A.push s
        w = s
    end
end
puts "Yes"


n = gets.to_i
ws = n.times.map { gets.chomp }

satisfied = (n - 1).times.all? do |i|
  ws[i][-1] == ws[i + 1][0]
end

puts ws.uniq.count == n && satisfied ? 'Yes' : 'No'


N = gets.to_i
arr = []
arr << gets.chomp
(N-1).times do
  prev = arr[-1][-1]
  w = gets.chomp
  if w[0] == prev || arr.include?(w)
    puts 'No'
    exit
  else
    arr << w
  end
end

puts 'Yes'


n = gets.chomp.to_i
hash = Hash.new{0}
prev_word = ""
n.times do
  word = gets.chomp
  if word[0] != prev_word[-1]
    puts "No"
    exit
  else
    hash[word] += 1
    if hash[word] > 1
      puts "No"
      exit
    end
  end
  prev_word = word
end
puts "Yes"


n = gets.chomp.to_i
hash = Hash.new{0}
prev_word = ""
n.times do
  word = gets.chomp
  if word[0] == prev_word[-1]
    puts "No"
    exit
  else
    hash[word] += 1
    if hash[word] > 1
      puts "No"
      exit
    end
  end
  prev_word = word
end
puts "Yes"


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

use std::collections::HashMap;

fn main() {
    let n: usize = read();
    let mut a: Vec<String> = vec![];
    let mut map: HashMap<String, bool> = HashMap::new();

    for _ in 0..n {
        a.push(read());
    }

    let mut prev: char = '?';

    for i in 0..a.len() {
        // println!("{}", prev);
        if i != 0 && a[i].chars().nth(0).unwrap() != prev {
            println!("No");
            return;
        }
        if map.contains_key(&a[i]) {
            println!("No");
            return;
        }
        let ac = a[i].clone();
        map.insert(ac, true);
        prev = a[i].chars().last().unwrap();
    }
    println!("Yes");
}


#[allow(unused_macros, dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros, dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros, dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(dead_code)]
struct UnionFind {
    parent: Vec<usize>,
    rank: Vec<usize>,
    size: Vec<usize>,
}

#[allow(dead_code)]
impl UnionFind {
    fn new(n: usize) -> UnionFind {
        let mut p = vec![0; n];
        for i in 0..n {
            p[i] = i;
        }
        return UnionFind {
            parent: p,
            rank: vec![0; n],
            size: vec![1; n],
        };
    }

    fn find(&mut self, x: usize) -> usize {
        if x == self.parent[x] {
            x
        } else {
            let p = self.parent[x];
            let pr = self.find(p);
            self.parent[x] = pr;
            pr
        }
    }

    fn same(&mut self, a: usize, b: usize) -> bool {
        self.find(a) == self.find(b)
    }

    fn unite(&mut self, a: usize, b: usize) {
        let a_root = self.find(a);
        let b_root = self.find(b);
        if a_root == b_root {
            return;
        }
        if self.rank[a_root] > self.rank[b_root] {
            self.parent[b_root] = a_root;
            self.size[a_root] += self.size[b_root];
        } else {
            self.parent[a_root] = b_root;
            self.size[b_root] += self.size[a_root];
            if self.rank[a_root] == self.rank[b_root] {
                self.rank[b_root] += 1;
            }
        }
    }

    fn get_size(&mut self, x: usize) -> usize {
        let root = self.find(x);
        self.size[root]
    }
}

const MOD_P: usize = 1000000007;

#[allow(dead_code)]
// fact(n) = n! mod p
fn fact(n: usize) -> usize {
    let mut acc = 1;
    for i in 1..n + 1 {
        acc = acc * i % MOD_P;
    }
    acc
}

#[allow(dead_code)]
fn mod_pow(b: usize, mut e: usize) -> usize {
    let mut base = b;
    let mut acc = 1;

    while e > 1 {
        if e % 2 == 1 {
            acc = acc * base % MOD_P;
        }
        e /= 2;
        base = base * base % MOD_P;
    }

    if e == 1 {
        acc = acc * base % MOD_P;
    }

    acc
}

#[allow(dead_code)]
fn comb(n: usize, r: usize) -> usize {
    // nCr = n! / (r! (n-r)!) = n! (r!)^(p-2) ((n-r)!)^(p-2)
    fact(n) * mod_pow(fact(r), MOD_P - 2) % MOD_P * mod_pow(fact(n - r), MOD_P - 2) % MOD_P
}

#[allow(dead_code)]
fn gcd(a: usize, b: usize) -> usize {
    if b > a {
        gcd(b, a)
    } else if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

#[allow(dead_code)]
fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        w: [String;n],
    }
    let mut hm = std::collections::HashSet::new();
    let ans = if (0..(n - 1)).all(|i| {
        let b = w[i].chars().nth(w[i].len() - 1) == w[i + 1].chars().nth(0);
        if hm.contains(&w[i]) {
            false
        } else {
            hm.insert(&w[i]);
            b
        }
    }) && !hm.contains(&w[n - 1])
    {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}


use std::io;
use std::collections::HashSet;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let n = buf.trim().parse::<i32>().ok().unwrap();
	let mut flag = true;
	let mut set = HashSet::new();
	let mut v:Vec<String> = Vec::new();
	for i in 0..n {
		let mut buf = String::new();
		io::stdin().read_line(&mut buf).expect("");
		let s1 = buf.clone();
		let s2 = buf.clone();
		if !set.insert(s1.trim().to_string()) {
			flag = false;
			break;
		}else{
			v.push(s2.trim().to_string());
		}
	}
	/*for i in &v {
		println!("{}", i);
	}*/
	if flag {
		for i in 1..n {
			let a:Vec<char> = v[i as usize].chars().collect();
			let b:Vec<char> = v[(i-1) as usize].chars().collect();
			if a[0] != b[b.len() - 1] {
				flag = false;
				break;
			}
		}
		if flag {
			println!("Yes");
		}else{
			println!("No");
		}
	}else{
		println!("No");
	}
}


use proconio::{fastout, input, marker::Chars};
use std::collections::HashSet;

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

    let mut f = true;
    let mut hs = HashSet::new();

    for i in 0..n - 1 {
        let si: String = s[i].iter().collect();
        if hs.contains(&si) {
            f = false;
        }
        if s[i][s[i].len() - 1] != s[i + 1][0] {
            f = false;
            break;
        }
        hs.insert(si);
    }

    if f {
        println!("Yes");
    } else {
        println!("No");
    }
}


use std::io;
use std::str::FromStr;

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

fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().chars().collect()
}

fn main() {
    let n: u64 = input();
    let mut words: Vec<Vec<char>> = Vec::new();
    let mut prev: Vec<char> = input_char_vec();
    for _ in 1..n {
        let w = input_char_vec();
        if words.contains(&w) || prev[prev.len() - 1] != w[0] {
            // println!("{:?}", w);
            println!("No");
            return;
        }
        prev = w.to_vec();
        words.push(w);
    }
    println!("Yes");
}


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

use std::collections::HashMap;

fn main() {
    let n: usize = read();
    let mut a: Vec<String> = vec![];
    let mut map: HashMap<String, bool> = HashMap::new();

    for _ in 0..n {
        a.push(read());
    }

    let mut prev: char = '?';

    for i in 0..a.len() {
        // println!("{}", prev);
        if a[i].chars().nth(0).unwrap() != prev {
            println!("No");
            return;
        }
        if map.contains_key(&a[i]) {
            println!("No");
            return;
        }
        let ac = a[i].clone();
        map.insert(ac, true);
        prev = a[i].chars().last().unwrap();
    }
    println!("Yes");
}


import Foundation

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

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

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

let N = readInt()!
var W = [readLine()!]
for i in 1..<N {
    let Wi = readLine()!
    if W.contains(Wi) || W[i-1].toArray().last! != Wi.toArray()[0] {
        print("No")
        break
    } else {
        W += [Wi]
    }
    if i == N-1 {
        print("Yes")
    }
}


let n = Int(readLine()!)!
var words: [String] = []
var ok = true
for _ in 0..<n { words.append(readLine()!) }
for i in 0..<n-1 {
  let endIndex = words[i].index(before: words[i].endIndex)
  let end = words[i][endIndex]
  let start = words[i+1][words[i+1].startIndex]
  ok = (end == start && ok)
}
if Set(words).count == words.count && ok {
  print("Yes")
} else {
  print("No")
}


let n = Int(readLine()!)!
var words: [String] = []
var ok = true
for _ in 0..<n { words.append(readLine()!) }
for i in 0..<n-1 {
  let endIndex = words[i].index(before: words[i].endIndex)
  let end = words[i][endIndex]
  let start = words[i+1][words[i+1].startIndex]
  ok = (end == start)
}
if Set(words).count == words.count && ok {
  print("Yes")
} else {
  print("No")
}


function Main(input: string) {
  const lines = input.split('\n');
  const params1 = lines[0].split(' ');

  const n = parseInt(params1[0]);
  const w = lines.slice(1, n + 1);

  let memory: { [s: string]: boolean } = {};
  let isShiritori = true;
  for (let i = 0; i < n; i++) {
    if ((memory[w[i]] !== undefined) ||
      (i !== 0 && w[i - 1][w[i - 1].length - 1] !== w[i][0])
    ) {
      isShiritori = false;
      break;
    }
    memory[w[i]] = true;
  }

  const msg = isShiritori ? 'Yes' : 'No';

  console.log(msg);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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


"use strict"
var int = x=>parseInt(x,10);var spln = x=>x.split(/\n/g);var spsp = x=>x.split(/\s/g);
function main(input) {
  var n = int(spln(input)[0]);
  var a = spln(input).slice(1,n+1);
  var s = new Set(a);
  if(a.length!==s.size){
    console.log('No');
    return;
  }else{
    for(let i=0;i<n;i++){
    if(!(a[i+1])){
      continue;
    }else if(a[i].split('').pop()!==a[i+1][0]){
        console.log('No')
        return;
      }
    }
    console.log('Yes');
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


var lines=[];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', function (line) {
  lines.push(line);
});
reader.on('close', function () {
  main(lines);
});

function main(lines) {
  const words = lines.slice(1).map(s => s.trim());
  const isOk = shiritori(words);
  console.log(isOk ? 'Yes' : 'No');
}

function shiritori(words) {
  const exists = [];
  let isOk = true;
  for (let word of words) {
    if (exists.length > 0) {
      const previous = exists[exists.length - 1];
      if (previous.slice(0, -1) !== word.slice(0, 1) || exists.some(e => e === word)) {
        isOk = false;
        break;
      } else {
        exists.push(word);
      }
    } else {
      exists.push(word);
    }
  }
  return isOk;
}


function Main(input: string):void {
    const [n, ...words] = input.split('\n');
    const firstChar = (str) => str[0];
    const lastChar = (str) => str[str.length - 1];

    let lastWord:string;
    const usedWords = new Set<string>();
    const ans = words.every((word) => {
        if (!lastWord || (firstChar(word) === lastChar(lastWord) && !usedWords.has(word))) {
            lastWord = word;
            usedWords.add(word);
            return true;
        }
        return false;
    });
    console.log(ans ? 'Yes' : 'No');
}

import * as fs from 'fs';
Main(fs.readFileSync('/dev/stdin', 'utf8'));


function Main(input: string):void {
    const [n, ...words] = input.split('\n');
    const firstChar = (str) => str[0];
    const lastChar = (str) => str[str.length - 1];

    let lastWord:string;
    const usedWords = {};
    const ans = words.every((word) => {
        if (!lastWord || (firstChar(word) === lastChar(lastWord) && !usedWords[word])) {
            lastWord = word;
            usedWords[word] = true;
            return true;
        }
        return false;
    });
    console.log(ans ? 'Yes' : 'No');
}

import * as fs from 'fs';
Main(fs.readFileSync("/dev/stdin", "utf8"));


a,b=map(int,input().split())
if b>=a:
    print(a)
else:
    print(a-1)


a, b = map(int, input().split())
print(a if a <= b else a - 1)


a,b=map(int,input().split())
if a>b:
    a-=1
print(a)


a,b=map(int, input().split())
q=0
for i in range(1,a+1):
  for j in range(1,b+1):
    if i==j:
      q+=1

print(q)


A, B = [int(i) for i in input().split()]

print(min(A, B))


a,b=map(int,input().split())

print(min(a,b))


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

public class Main {

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmpArray = br.readLine().split(" ");

		int a = Integer.parseInt(tmpArray[0]);
		int b = Integer.parseInt(tmpArray[1]);

		int result = 0;
		for(int i = 1; i <= a; i++){
			for(int j = 1; j <= 31; j++){
				if(i == j){
					result++;
				}
				if(i == a && j == b){
					break;
				}
			}
		}

		System.out.println(result);
	}

}


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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int[] a = nextInts();

		int ans =a[0];
		if(a[0]>a[1]){
			ans--;
		}

		System.out.println(ans);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}


import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = a;
		if (a > b) ans--;
		out(ans);
	}

	static class Combination {
		final int mod;
		final int max;

		final long[] fact;
		final long[] inv;
		final long[] invfact;

		public Combination(int n) {
			this(n, 1_000_000_007);
		}

		public Combination(int n, int mod) {
			this.mod = mod;
			max = n + 1;
			fact = new long[max];
			invfact = new long[max];
			inv = new long[max];

			inv[1] = 1;
			for (int i = 2; i < inv.length; i++) {
				inv[i] = inv[mod % i] * (mod - mod / i) % mod;
			}

			fact[0] = 1;
			invfact[0] = 1;
			for (int i = 1; i < inv.length; i++) {
				fact[i] = i * fact[i - 1] % mod;
				invfact[i] = inv[i] * invfact[i - 1] % mod;
			}
		}

		public long get(int n, int r) {
			return fact[n] * invfact[n - r] % mod * invfact[r] % mod;
		}
	}

	public static long gcd(long a, long b) {
		long remainder = a % b;
		if (remainder == 0) {
			return b;
		} else {
			return gcd(b, remainder);
		}
	}

	static void out(String a) {
		System.out.println(a);
	}

	static void out(int a) {
		System.out.println(a);
	}

	static void out(long a) {
		System.out.println(a);
	}

	static void out(double a) {
		System.out.println(a);
	}

	static void out(char a) {
		System.out.println(a);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

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

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

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

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

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

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

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


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);

		int a = stdIn.nextInt();
		int b = stdIn.nextInt();

		if(a <= b)
		{
			System.out.println(a);
		}
		else
		{
			System.out.println(b);
		}

	}

}


import java.util.*;
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		System.out.println(Math.min(a, Math.min(12,b)));
		sc.close();
	}

	public static void main(String args[]) {
		solve();
	}

}


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 a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(Math.min(a,b));
    }
}


#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define LL long long
#define uLL unsigned long long
int cmp(LL a,LL b,LL c,LL d)
{
	if (a==c)
	{
		return c-d;
	}
	else
	{
		return a-c;
	}
}
int main()
{
	LL i,j,k,a,b,c,ans;
	scanf("%lld%lld",&a,&b);
	ans=0;
	for (i=1;i<=12;i++)
	{
		if (cmp(i,i,a,b)<=0)
		{
			ans+=1;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


#include <cstdio>

int main(void){
    int a, b;

    scanf("%d%d", &a, &b);
    if (b>=a) printf("%d\n", a);
    else printf("%d\n", a-1);

    return 0;
}


#include<cstdio>

using namespace std;

int main(){
int a, b;

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

if(a == 1){
printf("1");
}else if(a > b){
a = a - 1;
printf("%d", a);
}else{
printf("%d", a);
}

return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int a, b;
    cin>>a>>b;
    cout<<min(a, b)<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a > b)
		cout << a << "\n";
	else
		cout << a + 1 << "\n";
}


/*
  Contest 096
  A - Day of Takahashi
  Rakesh Kumar --> 23/09/2020
 */

#include <bits/stdc++.h>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    int a = 0, b = 0;
    std::cin >> a >> b;
    std::cout << std::min(a, b) << std::endl;

    return 0;
}


/*

*/

#include<stdio.h>

int main() {
	int a, b, ans;
	scanf("%d %d", &a, &b);
	if(a<=b){
		ans = a;
	}
	else if (a>b){
		ans = a-1;
	}
	printf("%d\n", ans);
	//getch();
	return 0;
}


#include <stdio.h>

int main(){
	int a, b;

	scanf("%d %d", &a, &b);
	if(b < a) a--;
	printf("%d\n", a);
	return 0;
}


#include<stdio.h>

int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a>b){
    printf("%d",a - 1);
  }else{
    printf("%d",a);
  }
  return 0;
}


//例えば30月が存在して、かつうるう年なら崩壊するコード
#include <stdio.h>

int main(){
  int a,b;
  scanf("%d%d",&a,&b);

  int takahasiDayCount=0;
  for(int i=1; i <= a; i++){
    for(int j=1; j <= b; j++){
      if(i == j) takahasiDayCount++;
    }
  }
  printf("%d",takahasiDayCount);
}


#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>

int main(void)
{
  int a b;
  scanf("%d%d",&a,&b);
  if(a>b)
    printf("%d",a-1);
  else
    printf("%d",a);
	return 0;
}


#include<stdio.h>

int main()
{
  int a,b;

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

  int i,j;
  int count=0;

  for(i=1;i<=a;i++)
  {
    for(j=1;j<=b;j++)
    {
      if(i==j)
      {
        count++;
      }
    }
  }

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

  return 0;
}


function main(input) {
    var a = input[0].split(" ")[0]-0;
    var b = input[0].split(" ")[1]-0;

    console.log(a<=b?a:a-1);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


function Main(input){
var inputs =input.split(" ");
var a = parseInt(inputs[0],10);
var b = parseInt(inputs[1],10);
var count = 0;
count += (a-1);
if(b>=a){
  count += 1;
}
console.log(count);
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));


function Main(input) {
	input = input.trim();
  var mae = parseInt(input.split(" ")[0]);
  var ato = parseInt(input.split(" ")[1]);
  var output = mae;
  if(ato < mae){
     output--;
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function main(input){
  const a=input.trim().split(' ').map(Number);
  if(a[0]>=a[1]){
    console.log(a[0]);
  }else{
    console.log(a[0]-1);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main(input) {
   input = input.trim();
  const a = input.split(" ").map(Number);
 console.log(a[0] - 1 + (a[0] <= a[1] ? 1 : 0)

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main(input) {
    var a = input[0].split(" ")[0]-0;
    var b = input[0].split(" ")[1]-0;

    console.log(a<b?a:a-1);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"reflect"
	"sort"
	"strconv"
	"strings"
	// "regexp"
)

/* sort */
type pair struct {
	index  int64
	p1, p2 interface{}
}
type pairs []pair

func (slice pairs) Len() int {
	return len(slice)
}

func (slice pairs) Less(i, j int) bool {
	return slice[i].index < slice[j].index
}

func (slice pairs) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

/* sort */
type Int64Slice []int64

func (slice Int64Slice) Len() int {
	return len(slice)
}

func (slice Int64Slice) Less(i, j int) bool {
	return slice[i] < slice[j]
}

func (slice Int64Slice) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}
func Int64s(a []int64)                    { sort.Sort(Int64Slice(a)) }
func Int64sSliceAreSorted(a []int64) bool { return sort.IsSorted(Int64Slice(a)) }

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8
	INF            = 1e8
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	di      = []int64{-1, 0, 1, 0}
	dj      = []int64{0, -1, 0, 1}
)

func main() {
	buf := make([]byte, initialBufSize)
	scanner.Buffer(buf, maxBufSize)
	scanner.Split(bufio.ScanWords)
	a, b := readInt(), readInt()
	diff := a
	if b < a {
		diff--
	}
	fmt.Println(diff)
}

/*==========================================
 *             Library
 *==========================================*/
func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}
func doubleAry(h int64, w int64, init int64) (res [][]int64) {
	res = make([][]int64, h)
	for i := int64(0); i < h; i++ {
		res[i] = make([]int64, w)
		for j := int64(0); j < w; j++ {
			res[i][j] = init
		}
	}
	return
}

func aryEq(a []int64, b []int64) bool {
	return reflect.DeepEqual(a, b)
}

func clone(n []int64) (r []int64) {
	r = make([]int64, len(n))
	for i := 0; i < len(n); i++ {
		r[i] = n[i]
	}
	return
}
func write(s string) {
	writer.WriteString(s)
}

func print() {
	writer.Flush()
}

// scanner.Split(bufio.ScanWords) をコメントアウトしないと使用不可
func readLine() (s string) {
	if scanner.Scan() {
		s = scanner.Text()
	}
	return s
}

func readInt() (read int64) {
	scanner.Scan()
	read, err := strconv.ParseInt(scanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return
}

func readFloat() (read float64) {
	scanner.Scan()
	read, err := strconv.ParseFloat(scanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return
}

func readRunes() (read []rune) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, v)
	}
	return
}

func readString() (read string) {
	scanner.Scan()
	read = scanner.Text()
	return
}

func readStrings() (read []string) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, string(v))
	}
	return
}

func s2i(s string) int64 {
	var intVal, e = strconv.ParseInt(s, 10, 64)
	if e != nil {
		panic(e)
	}
	return intVal
}

func i2s(i int64) string {
	var strVal = strconv.FormatInt(i, 10)
	return strVal
}

func s2f(s string) float64 {
	var floatVal, e = strconv.ParseFloat(s, 64)
	if e != nil {
		panic(e)
	}
	return floatVal
}

func abs(i int64) int64 {
	return int64(math.Abs(float64(i)))
}

func max(a ...int64) int64 {
	ans := int64(0)
	for i, v := range a {
		if i == 0 {
			ans = v
		}
		if ans < v {
			ans = v
		}
	}
	return ans
}
func min(a ...int64) int64 {
	ans := int64(0)
	for i, v := range a {
		if i == 0 {
			ans = v
		}
		if ans > v {
			ans = v
		}
	}
	return ans
}

func sum(i []int64) int64 {
	sum := int64(0)
	for _, val := range i {
		sum += val
	}
	return sum
}

func split(s string) []string {
	return strings.Fields(s)
}

func strAry2intAry(strs []string) []int64 {
	var ret = make([]int64, 0, len(strs))
	for _, str := range strs {
		var intVal = s2i(str)
		ret = append(ret, intVal)
	}
	return ret
}

func intAry2strAry(nums []int64) []string {
	var ret = make([]string, 0, len(nums))
	for _, num := range nums {
		var strVal = i2s(num)
		ret = append(ret, strVal)
	}
	return ret
}

func ary2str(strs []string) string {
	return strings.Join(strs, " ")
}

func reverse(res []int64) []int64 {
	for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
		res[i], res[j] = res[j], res[i]
	}
	return res
}
func reverseStr(res []string) []string {
	for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
		res[i], res[j] = res[j], res[i]
	}
	return res
}

func ini(res []int, init int) {
	if len(res) == 0 {
		return
	}
	res[0] = init
	for i := 0; i < len(res); i++ {
		copy(res[i:], res[:i])
	}
}

//
// func regexpExample() {
//     // Your code here!
//     var str = "13:20"
//     r := regexp.MustCompile(`(\d+):(\d+)`)
//     fmt.Println(r.FindStringSubmatch(str))
// }

// type Country struct {
//     gold int
//     silver int
//     blonze int
// }

// // 複数ソートのサンプル
// func stableSortExample() []Country{
//     var country = []Country {
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:3, blonze:2},
//         {gold:1, silver:3, blonze:3},
//     }
//     sort.SliceStable(country, func(i, j int) bool { return country[i].blonze > country[j].blonze })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].silver > country[j].silver })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].gold > country[j].gold })
//     return country
// }


package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	ans := a
	if b < a {
		ans--
	}

	fmt.Println(ans)
}


package main

import (
	. "fmt"
)

// func init() { Println("----------------------------------------") }

func main() {
    var a, b int
    Scanf("%d %d", &a, &b)

    if b >= a {
        Println(a)
    } else {
        Println(a - 1)
    }
}


package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a > b {
	  fmt.Println(a)
	} else {
		fmt.Println(a - 1)
	}
}


package main

import "fmt"

func main() {
	var a, b int

	fmt.Scanf("%d %d", &a, &b)

	var total int = 0
	for i := 1; i <= 12; i++ {
		if i <= a {
			if i <= b {
				total++
			} else {
				break
			}
		} else {
			break
		}
	}

	fmt.Println(total)
}


package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	a := getInt()
	b := getInt()

	cnt := 0
	for m := 1; m <= a; m++ {
		if m <= b {
			cnt++
		}
	}
	fmt.Println(cnt)
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

func bfs(c int, graph *Graph) {
	next := make([]int, 0)
	next = append(next, c)
	visited := make(map[int]struct{})

	for ; len(next) != 0; {
		u := next[0]
		next = next[1:]
		visited[u] = struct{}{}

		for _, v := range graph.edges[u] {
			_, flag := visited[v]
			if flag {
				continue
			}

			// なにか処理

			next = append(next, v)
		}
	}
}

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

func getIntArray(n int) []int {
	array := make([]int, n)
	for i := 0; i < n; i++ {
		array[i] = getInt()
	}
	return array
}

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

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return calcMod(n * powMod(n, p-1))
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func isPrime(n int) bool {
	if n < 2 {
		return false
	} else if n == 2 {
		return true
	} else if n % 2 == 0 {
		return false
	}

	sqrtN := int(math.Sqrt(float64(n)))
	for i := 3; i <= sqrtN; i += 2 {
		if n % i == 0 {
			return false
		}
	}

	return true
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

func makeRange(min, max int) []int {
	a := make([]int, max-min+1)
	for i := range a {
		a[i] = min + i
	}
	return a
}

func powerset2(nums []int) [][]int {
	length := int(math.Pow(2, float64(len(nums))))
	result := make([][]int, length)

	index := 0
	result[index] = []int{}
	index++

	for _, n := range nums {
		max := index
		for i := 0; i < max; i++ {
			result[index] = copyAndAppend(result[i], n)
			index++
		}
	}

	return result
}

func copyAndAppend(nums []int, n int) []int {
	dst := make([]int, len(nums)+1)
	copy(dst, nums)
	dst[len(nums)] = n
	return dst
}

func calcGcd(x, y int) int {
	if y == 0 {
		return x
	} else if x >= y {
		return calcGcd(y, x % y)
	} else {
		return calcGcd(x, y % x)
	}
}

func getDivisor(n int) []int {
	var divisor []int
	divisor = append(divisor, 1)
	if n != 1 {
		divisor = append(divisor, n)
	}

	sqrt := int(math.Sqrt(float64(n)))
	for i := 2; i <= sqrt; i++ {
		if n % i == 0 {
			divisor = append(divisor, i)
			divisor = append(divisor, n/i)
		}
	}
	return divisor
}

type intHeap []int

func (h intHeap) Len() int {
	return len(h)
}

func (h intHeap) Less(i, j int) bool {
	return h[i] > h[j]
}

func (h intHeap) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}

func (h *intHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *intHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func initHeap() *intHeap {
	ih := &intHeap{}
	heap.Init(ih)
	return ih
}

func (h *intHeap) pushHeap(n int) {
	heap.Push(h, n)
}

func (h *intHeap) popHeap() int {
	return heap.Pop(h).(int)
}

func factMod(n int) int {
	value := 1
	for ; n > 1; n-- {
		value = calcMod(value * n)
	}
	return value
}

func combinationMod(n, k int) int {
	factN := factMod(n)
	factK := factMod(k)
	factNK := factMod(n - k)
	factKR := powMod(factK, mod - 2)
	factNKR := powMod(factNK, mod - 2)
	return calcMod(factN * calcMod(factKR * factNKR))
}


a, b = gets.chomp.split.map(&:to_i)
puts (a > b)? a - 1 : a


a, b = gets.chomp.split.map(&:to_i)

if a <= b
  puts a
elsif
  puts a - 1
end


a = gets.split(' ').map(&:to_i)
if a[0] > a[1]
    p a[0] - 1
else
    p a[0]
end


a,b = gets.split.map(&:to_i)
ans = 0
(1..a).each do |i|
  ans += 1 if i <= b
end

puts ans


m,d = gets.split.map(&:to_i)
if m < d
  puts m - 1
else
  puts m
end


a, b = gets.chomp.split.map(&:to_i)

if a == b
  puts a
elsif a != b
  puts a - 1
end


use std::io::*;
use std::str::FromStr;

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

fn main() {
    let a: usize = read();
    let b: usize = read();

    println!(
        "{}",
        match b >= a {
            true => a,
            false => a - 1,
        }
    )
}