jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]


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;
        }
    }
}
//  [java]
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);
	}
}
//  [java]
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());
        }
    }
}
//  [cpp]
#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;
}
//  [cpp]
#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";
}
//  [cpp]
#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;
}
//  [cpp]
#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;
}
//  [cpp]
#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;
  }
}
//  [cpp]
#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;
  }
}
//  [c]
#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;
}
//  [c]
#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;
}
//  [c]
#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;
}
//  [c]
#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;
}
//  [c]
#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 ;
}
//  [c]
#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 ;
}
//  [javascript]
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"))
//  [javascript]
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.split(" ");
	input = input.split("\n");
	//input = input.split(" ").map((a)=>Number(a));
	//input = input.split("\n").map((a)=>Number(a));
  var 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());
//  [javascript]
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"))
//  [javascript]
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'));
//  [javascript]
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'));
//  [go]
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")
}
//  [go]
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")
}
//  [go]
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
}
//  [go]
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
}
//  [go]
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")
}
//  [ruby]
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'
//  [ruby]
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"
//  [ruby]
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'
//  [ruby]
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'
//  [ruby]
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"
//  [ruby]
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"
//  [rust]
use std::io::*;
use std::str::FromStr;

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

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");
}
//  [rust]
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");
	}
}
//  [rust]
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");
    }
}
//  [rust]
use std::io;
use std::str::FromStr;

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

fn 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");
}
//  [rust]
use std::io::*;
use std::str::FromStr;

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

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");
}
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#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")
    }
}
//  [swift]
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")
}
//  [swift]
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")
}
//  [typescript]
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'));
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};
const 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()
//  [typescript]
"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'));
//  [typescript]
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;
}
//  [typescript]
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'));
//  [typescript]
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"));
//  [python]
a,b=map(int,input().split())
if b>=a:
    print(a)
else:
    print(a-1)
//  [python]
a, b = map(int, input().split())
print(a if a <= b else a - 1)
//  [python]
a,b=map(int,input().split())
if a>b:
    a-=1
print(a)
//  [python]
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)
//  [python]
A, B = [int(i) for i in input().split()]

print(min(A, B))
//  [python]
a,b=map(int,input().split())

print(min(a,b))
//  [java]
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);
	}

}
//  [java]
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;
	}


}
//  [java]
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);
		}

	}

}
//  [java]
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();
	}

}
//  [java]
import java.util.*;
import java.io.*;
import java.lang.*;

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

        System.out.println(Math.min(a,b));
    }
}
//  [cpp]
#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;
}
//  [cpp]
#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;
}
//  [cpp]
#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;
}
//  [cpp]
#include<iostream>
using namespace std;
int main()
{
    int a, b;
    cin>>a>>b;
    cout<<min(a, b)<<endl;
    return 0;
}
//  [cpp]
#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";
}
//  [cpp]
/*
  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;
}
//  [c]
/*

*/

#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;
}
//  [c]
#include <stdio.h>

int main(){
	int a, b;

	scanf("%d %d", &a, &b);
	if(b < a) a--;
	printf("%d\n", a);
	return 0;
}
//  [c]
#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;
}
//  [c]
//例えば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);
}
//  [c]
#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;
}
//  [c]
#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;
}
//  [javascript]
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"))
//  [javascript]
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'));
//  [javascript]
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"));
//  [javascript]
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'));
//  [javascript]
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'));
//  [javascript]
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"))
//  [go]
package main

import (
	"fmt"
)

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

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

	fmt.Println(ans)
}
//  [go]
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)
    }
}
//  [go]
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)
	}
}
//  [go]
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)
}
//  [ruby]
a, b = gets.chomp.split.map(&:to_i)
puts (a > b)? a - 1 : a
//  [ruby]
a, b = gets.chomp.split.map(&:to_i)

if a <= b
  puts a
elsif 
  puts a - 1
end
//  [ruby]
a = gets.split(' ').map(&:to_i)
if a[0] > a[1] 
    p a[0] - 1
else
    p a[0]
end
//  [ruby]
a,b = gets.split.map(&:to_i)
ans = 0
(1..a).each do |i|
  ans += 1 if i <= b
end

puts ans
//  [ruby]
m,d = gets.split.map(&:to_i)
if m < d
  puts m - 1
else
  puts m
end
//  [ruby]
a, b = gets.chomp.split.map(&:to_i)

if a == b
  puts a
elsif a != b
  puts a - 1
end
//  [rust]
use std::io::*;
use std::str::FromStr;

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

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

    println!(
        "{}",
        match b >= a {
            true => a,
            false => a - 1,
        }
    )
}
//  [rust]
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let (a, b): (usize, usize);
    input!(a, b);

    if a <= b {
        println!("{}", a);
    } else {
        println!("{}", a - 1);
    }
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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! {
        a: u32,
        b: u32,
    }
    if a <= b {
        println!("{}", a);
    } else {
        println!("{}", a - 1);
    }
}
//  [rust]
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

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

    println!("{}", min(a,b));

}
//  [rust]
use std::io::Read;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    min(a, b).to_string()

    // let mut ans = 0;
    // for i in 1..=a {
    //     for j in 1..=b {
    //         if i == j {
    //             ans += 1;
    //         }
    //     }
    // }
    // ans.to_string()
}