jiahuimbzuai/CoQuIR huggingface dataset:
//  [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(-1) !== word.slice(0, 1) || exists.some(e => e === word)) {
        isOk = false;
        break;
      } else {
        exists.push(word); 
      }
    } else {
      exists.push(word);  
    }
  }
  return isOk;
}
//  [typescript]
import * as fs from 'fs';

namespace Atcoder.abc109 {


    class ProgramB {

        inp: string = '';

        /**
         9
         basic
         c
         cpp
         php
         python
         nadesico
         ocaml
         lua
         assembly

         Yes
         */
        constructor(inp: string) {
            this.inp = inp;
        }

        main() {
            const inpArr: string[] = this.inp.split('\n');

            const n: number = parseInt(inpArr[0], 10);
            inpArr.shift();

            let flg = true;
            inpArr.reduce((prev: string, curr: string, idx: number, arr: string[]) => {
                if (prev[prev.length - 1] !== curr[0]) {
                    flg = false;
                }

                if (arr.filter((val: string) => {
                    return (val === curr);
                }).length >= 2) {
                    flg = false;
                }

                return curr;
            }, inpArr[0][0]);


            console.log(flg ? 'Yes' : 'No');
        }
    }

    const func = new ProgramB(fs.readFileSync('/dev/stdin', 'utf8').trim());
    func.main();
}
//  [python]
S = input()
length = len(S)
ans = 0

for i in range(length):
    ans += sum([int(S[i]) * (10**k) * 2**(max(0, length-i-k-2) + i) for k in range(length - i)])

print(ans)
//  [python]
def F(S):
    if len(S) ==1:
        return S[0]
    else:
        S1 = [(10*S[0]+S[1])]+S[2:]
        S2 = S[1:]
        return F(S1)+F(S2)+S[0]*(2**(len(S)-2))

s = input()
x = [int(s[i]) for i in range(len(s))]
print(F(x))
//  [python]
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**9


def f():
    s = input()
    l = len(s)
    sa = [c for c in s]
    m = 2**(l-1)
    r = 0
    for i in range(m):
        si = sa[0]
        for j in range(l-1):
            t = 2**j
            if i & t:
                si += '+'
            si += sa[j+1]
        r += eval(si)
    return r

print(f())
//  [python]
def get(s):
    length = len(s)
    sum = 0
    for i in range(length):
        sum += int(s[0:i+1])
        sum += get(s[i+1:])
        if len(s[i+1:]) != 0:
            sum += (2**(len(s[i+1:])-1)-1)*int(s[0:i+1])
    return int(sum)

def main():
    string = str(input())
    print(int(get(string)))

main()
//  [python]
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
S = list(input())

l = len(S)

anss = []
for i in range(1<<l-1):
	ans = []
	i = list("{:b}".format(i).zfill(l-1))
	#print(i)
	S_ = S.copy()
	ans.append(S_.pop(0))
	while S_ != []:
		if i.pop(0) == "1":
			ans.append("+")
		ans.append(S_.pop(0))
		#print(ans)
	anss.append(eval("".join(ans)))
#print(anss)
print(sum(anss))
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    char[] cs;
    long allSum = 0;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        cs = sc.next().toCharArray();
        solve();
    }

    void solve() {
        dfs(0, 0, 0);
        System.out.println(allSum);
    }

    void dfs(int pointer, long sum, long rem) {
        if (pointer == cs.length - 1) {
            allSum += sum + Character.getNumericValue(cs[pointer]) + rem * 10;
            return;
        }
        int num = Character.getNumericValue(cs[pointer]);
        dfs(pointer + 1, sum + rem * 10 + num, 0);
        dfs(pointer + 1, sum, rem * 10 + num);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}
//  [java]
import java.io.*;
import java.util.*;

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    int[] a;
    int n;
    private void solve(){
        String s = in.nextLine();
        a= new int[s.length()];
        n = s.length();
        for(int i=0;i<s.length();i++){
            a[i] =s.charAt(i)-'0';
        }
        long ret = 0;
        for(int i=0;i<(1<<n-1);i++){
            int st = 0;
            for(int j=0;j<n-1;j++){
                if((i & (1<<j))!=0){
                    ret+= calculate(st,j);
                    st = j+1;
                }
            }
            ret+=calculate(st,n-1);
            //out.println(ret + " "+i);
        }

        out.print(ret);
    }

    private long calculate(int s, int e){
        //out.println(s+" "+e);
        long v = 0;
        for(int i=s;i<=e;i++){
            v = v*10+a[i];
        }
        return v;
    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

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

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

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}
//  [java]
import java.util.*;

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

    char[] input = scan.next().toCharArray();
    int[] arr = new int[input.length];
    for(int i = 0; i < arr.length; i++) arr[i] = (int)(input[i]-'0');

    int maxLoop = 1<<(arr.length-1);
    long result = 0;
    for(int i = 0; i < maxLoop; i++) {
      long sum = 0;
      long dummySum = arr[0];
      for(int j = 0; j < arr.length-1; j++) {
        if((i&(1<<j))==0) {
          dummySum*=10;
          dummySum += arr[j+1];
        }else {
          sum += dummySum;
          dummySum = arr[j+1];
        }
      }
      sum += dummySum;
      //System.out.println(Integer.toBinaryString(i)+","+sum);
      result += sum;
    }

    System.out.println(result);
  }
}
//  [java]
import java.math.BigDecimal;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String str=s.next();
		long result=0;
		
		for(int i=0;i<str.length();i++){
			int no = Integer.parseInt(""+str.charAt(i));
			for(int j=0;j<str.length()-i;j++){
				result += no*Math.pow(10, j)*Math.pow(2, i)*Math.pow(2, Math.max(str.length()-2-j-i,0));
			}
		}
			
		System.out.println(result);
	}
}
//  [java]
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static char[] S;

	public static void main(String[] args) {
		S = sc.next().toCharArray();
		System.out.println(solve(0, S.length));
	}

	static long solve(int l, int r) {
		if (l == r) return 0;
		long ret = Long.parseLong(String.valueOf(S, l, r - l));
		for (int i = 1; l + i < r; ++i) {
			long base = Long.parseLong(String.valueOf(S, l, i));
			ret += base * (1 << (r - l - 1 - i)) + solve(l + i, r);
		}
		return ret;
	}

}
//  [cpp]
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

long long int ans;
int a[15];

void total(int i, long long int num, long long int tot){
    if (a[i+1]<0) ans += tot + num * 10 + a[i];
    else{
        total(i+1, 0, tot+ 10 * num + a[i]);
        total(i+1, num * 10 + a[i], tot);
    }
}


int main(){
    char S[15];
    scanf("%s", &S);

    int num = strlen(S);
    for(int i = 0; i < num; i++){
        char c[3] = {S[i]};
        a[i] = atoi(c);
    }
    a[num] = -1;
    ans = 0;

    total(0, 0, 0);
    printf("%lld\n", ans);
    return 0;
}
//  [cpp]
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;


int main() {
	
	string p;
	int x;
	cin >> p ;

	long long int ans = 0;
	int n=p.size();

	for (int i = 0; i < 1<<n-1; i++) {
		long long int y = p[0] - '0';
		for (int j = 0; j < n - 1; j++) {
			if (i & 1 << j) {
				ans += y; y = 0;
			}
			y = y * 10 + p[j + 1] - '0';
		}
		ans += y;
	}
	cout << ans << endl;
	
	return 0;

}
//  [cpp]
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<bool> V;
typedef map<int, int> M;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

string s;

ll solve(int n, V pos)
{
    ll res = 0;

    if (n == s.size() - 1)
    {
        ll cnt = 1;
        for (int i = s.size() - 1; i >= 0; i--)
        {
            if (pos[i])
                cnt = 1;
            res += (s[i] - '0') * cnt;

            cnt *= 10;
        }

        return res;
    }

    pos.push_back(true);

    res += solve(n + 1, pos);

    pos[pos.size() - 1] = false;

    res += solve(n + 1, pos);

    return res;
}

int main()
{

    cin >> s;

    V pos;

    cout << solve(0, pos) << endl;

    return 0;
}
//  [cpp]
#include<iostream>
#include<string>
using namespace std;
long long res=0;
long long now=0;
string s;

void f(int i,long long pp)
{
	if(i==s.size())
	{
		res+=now+pp;
		return;
	}

	long long temp=now;

	now+=pp;
	f(i+1,s[i]-'0');

	now=temp;
	f(i+1,pp*10+s[i]-'0');
}

int main()
{
	cin>>s;
	f(1,s[0]-'0');
	cout<<res;
	return 0;
}
//  [cpp]
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back      
#define F first
#define S second
#define SS stringstream
#define sqr(x) ((x)*(x))
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define CC(x) cout << (x) << endl
#define pw(x) (1ll<<(x))
#define buli(x) __builtin_popcountll(x)
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define M 1000000007
#define N 211111

#define TASK "1"

using namespace std;

int main(){
	#ifdef home
		freopen(TASK".in","r",stdin);	
		freopen(TASK".out","w",stdout);
	#endif		
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	long long ans = 0;

	for (int o = 0; o < pw(s.size() - 1); o++) {
		SS q;
		for (int i = 0; i < s.size(); i++) {
			q << s[i];
			if (o & pw(i)) q << " ";
		}
		long long x;
		while ((q >> x)) ans += x;
	}
	cout << ans << endl;
	return 0;
}
//  [c]
#include <stdio.h>
#include <math.h>
#include <string.h>

int main()
{
  char ss[11];
  long long int nn, order, sum = 0;
  scanf("%s", ss);
  nn = strlen(ss);
  for(int bit = 0;bit < (1 << (nn - 1));bit++)
  {
    order = 1;
    sum += ss[nn - 1] - '0';
    for(int ii = 1;ii < nn;ii++)
    {
      if(bit & (1 << (ii - 1)))
      {
        sum += (ss[nn - 1 - ii] - '0');
        order = 1;
      }
      else
      {
        sum += (ss[nn - 1 - ii] - '0') * pow(10, order);
        order++;
      }
    }
  }
  printf("%lld\n", sum);
  return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    char s[11];
    int i,j,len;
    long g=0;
    scanf("%s",s);
    len=strlen(s);
    for(i=0;i<(1<<(len-1));i++){
        char siki[20]={'\0'};
        siki[0]=s[0];
        for(j=0;j<len-1;j++){
            if(i&(1<<j))
                sprintf(siki,"%s%c%c",siki,'+',s[j+1]);
            else
                sprintf(siki,"%s%c",siki,s[j+1]);
        }
        long tmp=0;
        for(j=0;siki[j]!='\0';j++){
            if(siki[j]!='+')
                tmp = tmp*10+(siki[j]-'0');
            else{
                g+=tmp;
                tmp=0;
            }
        }
        g+=tmp;
    }
    printf("%ld\n",g);
    return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){

  int n;
  char s[15];
  long long ans = 0;
  long long sum = 0;
  int i,j;

  scanf("%s", s);
  n = strlen(s) - 1;

  for(i = 0;i < 1 << n;i++){
    sum = s[0] - '0';
    for(j = 0;j < n;j++){
      if(i >> j & 1){
        ans += sum;
        sum = (s[j + 1] - '0');
      }

      else sum = 10*sum + (s[j + 1] - '0');
    }

    ans += sum;
  }
  
  printf("%lld\n", ans);

  return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007
//#define DEBUG

int plus[16];
char numbers[16];
long int sum;
int len;

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(array, 10, sizeof(int), compare_int)

void culc(int i)
{
	if(i == len-1){
		long int term;

		term = 0;
		for(int j=0; j<len-1; j++){
			term += numbers[j] - '0';
			if(plus[j] != -1){
				sum += term;
				//printf("term:%ld\n", term);
				term = 0;
			}
			else{
				term = term*10;
			}
		}
		term += numbers[len-1] - '0';
		//printf("term:%ld\n", term);
		sum += term;

		return;
	}
	
	plus[i] = -1;
	culc(i+1);
	plus[i] = 1;
	culc(i+1);

	return;
}

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

	len = strlen(numbers);
	for(int i=0; i<16; i++){
		plus[i] = -1;
	}

	sum = 0;
	culc(0);

	printf("%ld\n", sum);
	
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

long long culc_sum(char data[], int len, int last_i, int i, long long sum);
char* slice(char data[], char temp[], int n);

int main(void)
{
  char s[10 + 1];
  int len;
  long long sum;

  /*入力*/
  scanf("%s", s);
  /*sの長さを計測*/
  len = 0;
  while (s[len] != '\0') {
    len++;
  }
  /*処理*/
  sum = culc_sum(s, len, 0, 1, 0);

  /*出力*/
  printf("%lld\n", sum);
  return 0;
}

long long culc_sum(char data[], int len, int last_i, int i, long long sum)
{
  char *temp, *end;
  long long sum_1 = 0, sum_2 = 0, plus = 0;

  if (i == len) {
    temp = malloc(i - last_i + 1);
    plus = strtoll(slice(data+last_i, temp, i - last_i), &end, 10);
    free(temp);
    return sum + plus;
  }

  temp = malloc(i - last_i + 1);
  plus = strtoll(slice(data+last_i, temp, i - last_i), &end, 10);
  free(temp);
  /*+を入れないパターン*/
  sum_1 = culc_sum(data, len, last_i, i+1, sum);
  /*+を入れるパターン*/
  sum_2 = culc_sum(data, len, i, i+1, sum+plus);

  return sum_1 + sum_2;
}

char* slice(char data[], char temp[], int n)
{
  strncpy(temp, data, n);
  temp[n] = '\0';
  return temp;
}
//  [c]
#include<stdio.h>
#define ll long long
ll int func(ll a,ll b,ll c){
     if(a/b==0){return a+c;} 
return func(a/b,10,c+a%b)+func(a,b*10,c);
}
int main(){
  ll int a;
  scanf("%lld",&a);
printf("%lld",func(a,10,0));
  return 0;
}
//  [javascript]
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n")[0],t=r.length,n=[],o=0;o<t;o++)n.push(0);var u=function e(r,t,n,o){if(t==n-1){for(var u="",i=0;i<n;i++)u+=o[i],1==r[i]&&(u+="+");for(var f=u.split("+"),c=0,l=0;l<f.length;l++)c+=Number(f[l]);return c}var a=r.concat();var p=e(a,t+1,n,o);var d=r.concat();d[t]=1;var s=e(d,t+1,n,o);return p+s}(n,0,t,r);console.log(u)}},function(e,r){e.exports=require("fs")}]);
//  [javascript]
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var list = myconv(next(),6);
  var N = list.length - 1;
  var output = 0;
  for(var i = 0; i < (1 << N); i++){
    var s = list[0];
    for(var j = 0; j < N; j++){
      if((i & (1 << j)) != 0){
         s += "+" + list[j + 1];
      }else{
         s += list[j + 1];
      }
    }
    var adder = s.split("+").map((a) => Number(a));
    for(var j = 0; j < adder.length; j++){
      output += adder[j];
    }
  }
  myout(output);
}
//  [javascript]
'use strict'
const lines = require('fs').readFileSync(0, 'utf8').split('\n')
const str = lines[0]
const n = str.length - 1;
const dfs = (i, sum, order) => {
  if (i === n) return eval(order + str[n]);

  sum += dfs(i + 1, sum, order + str[i] + '+') + dfs(i + 1, sum, order + str[i]);

  return sum;
}

const ans = dfs(0, 0, '');
console.log(ans);
//  [javascript]
"use strict";

var main = function main(input) {
  var S = input.trim();
  var N = S.split('').length;
  var list = [];
  list.push(S);

  for (var i = 0; i < N - 1; i++) {
    var list2 = [];

    for (var j = 0; j < list.length; j++) {
      var s = list[j]; // +入れない方

      list2.push(s); // +入れる方

      var pattern = /[0-9]/;
      var count = 0;
      var sAlter = "";

      for (var k = 0; k < s.split('').length; k++) {
        var c = s.split('')[k];

        if (pattern.test(c)) {
          count++;
        }

        if (count == i + 1) {
          sAlter = s.substring(0, k + 1) + '+' + s.substring(k + 1);
        }
      }

      list2.push(sAlter);
    }

    list = list2;
  }

  var result = 0;
  list.forEach(function (elem) {
    result += parseInt(elem.split('+').reduce(function (prev, current) {
      return parseInt(prev, 10) + parseInt(current, 10);
    }), 10);
  });
  console.log(result);
};

main(require('fs').readFileSync('/dev/stdin', 'utf-8'));
//  [javascript]
"use strict";

var main = function main(input) {
  var S = input.trim();
  var N = S.split('').length;
  var list = [];

  for (var i = 0; i < Math.pow(2, N - 1); i++) {
    var s = S;

    for (var j = 0; j < N; j++) {
      if (i >> j & 1) {
        var pattern = /[0-9]/;
        var count = 0;

        for (var k = 0; k < s.split('').length; k++) {
          var c = s.split('')[k];

          if (pattern.test(c)) {
            count++;
          }

          if (count == j + 1) {
            s = s.substring(0, k + 1) + '+' + s.substring(k + 1);
            break;
          }
        }
      }
    }

    list.push(s);
  }

  var result = 0;
  list.forEach(function (elem) {
    result += parseInt(elem.split('+').reduce(function (prev, current) {
      return parseInt(prev, 10) + parseInt(current, 10);
    }), 10);
  });
  console.log(result);
};

main(require('fs').readFileSync('/dev/stdin', 'utf-8'));
//  [javascript]
function Main(input){
    const S = input.trim();
    const dfs = (t, i) => {
        if(i==S.length-1)
            return t.split("+").map((x) => Number(x)).reduce((a,b) => Number(a)+Number(b));
        return  dfs(t+S[i+1], i+1) + dfs(t+"+"+S[i+1], i+1);
    }
    console.log(dfs(S[0],0));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// https://teratail.com/questions/272708
//  [go]
package main

import (
	"fmt"
	"math"
)

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

	num := make([]int, len(S))
	for i, r := range S {
		num[i] = int(r - '0')
	}

	arr := make([]int, 0, (1 << uint(len(S))))
	for bit := 0; bit < (1 << uint(len(S)-1)); bit++ {
		s := 0
		for i := 0; i < len(S); i++ {
			if bit&(1<<uint(i)) == (1 << uint(i)) {
				p := pow(num[s : i+1])
				arr = append(arr, p)
				s = i + 1
			}
		}
		arr = append(arr, pow(num[s:len(num)]))
	}

	sum := 0
	for i := range arr {
		sum += arr[i]
	}
	fmt.Println(sum)

}

func pow(data []int) int {
	if len(data) == 1 {
		return data[0]
	}

	sum := 0
	for i := 0; i < len(data); i++ {
		sum += data[i] * int(math.Pow10(len(data)-i-1))
	}
	return sum
}
//  [go]
package main

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

func main() {
	s := readString()

	fmt.Println(dfs(0, s))
}

func dfs(sum int, s string) int {
	result := sum
	for i := 1; i < len(s); i++ {
		a, _ := strconv.Atoi(s[0:i])
		result += dfs(sum+a, s[i:])
	}
	a, _ := strconv.Atoi(s)
	return result + a
}

/*-------------------utilities-------------------*/

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

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

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

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

// 最大公約数
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

// 最小公倍数
func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func comb(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7

	COMB_MAX = 510000
)

var (
	readString func() string
)

var (
	fac  = [COMB_MAX]int{}
	finv = [COMB_MAX]int{}
	inv  = [COMB_MAX]int{}
)

func init() {
	readString = newReadString(os.Stdin)
}

func combInit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < COMB_MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}
//  [go]
package main

import "fmt"

var s string

func main() {
	fmt.Scan(&s)
	n := len([]rune(s))
	digits := make([]int, n)
	for i, c := range s {
		digits[i] = int(c - '0')
	}

	ans := 0
	for bit := 0; bit < 1<<uint(n-1); bit++ {
		cursor := 0
		for i := 0; i < n-1; i++ {
			if bit&(1<<uint(i)) > 0 {
				ans += todecimal(digits[cursor : i+1])
				cursor = i + 1
			}
		}
		if cursor != n {
			ans += todecimal(digits[cursor:n])
		}
	}
	fmt.Println(ans)
}

func todecimal(ds []int) int {
	ans := ds[0]
	if len(ds) != 1 {
		for i := 1; i < len(ds); i++ {
			ans *= 10
			ans += ds[i]
		}
	}
	return ans
}
//  [go]
package main

import (
	"fmt"
	"go/token"
	"go/types"
	"strconv"
)

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

	l := len(S)

	total := 0
	for i := 0; i < (1 << uint(l-1)); i++ {
		formula := string(S[0])
		for j := 0; j < (l - 1); j++ {
			if i&(1<<uint(j)) > 0 {
				formula += "+"
			}
			formula += string(S[j+1])
		}
		res, err := types.Eval(token.NewFileSet(), nil, token.NoPos, formula)
		if err != nil {
			panic(err)
		}
		sum, err := strconv.Atoi(res.Value.String())
		if err != nil {
			panic(err)
		}
		total += sum
	}
	fmt.Println(total)
}
//  [go]
package main

import (
	"fmt"
	"strconv"
)

func main() {
	// Code for C - Many Formulas
	var S string
	fmt.Scan(&S)

	var n int = len(S) - 1
	var flag string
	var temp string
	var ans int
	var sum int
	var num int
	for i := 0; i < (1 << n); i++ { // 全ての探索候補 00,01,10,11
		flag = ""
		for j := 0; j < n; j++ { // 各行の網羅
			flag += S[j : j+1]
			if i>>j&1 == 1 { // 判定
				flag += "+"
			}
		}
		flag += S[len(S)-1 : len(S)]
		temp = ""
		ans = 0
		for j := 0; j < len(flag); j++ {
			if flag[j] == '+' {
				num, _ = strconv.Atoi(temp)
				temp = ""
				ans += num
			} else {
				temp += flag[j : j+1]
			}
		}

		if temp != "" {
			num, _ = strconv.Atoi(temp)
			ans += num
		}

		sum += ans
	}

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

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	S := next()

	var start int
	var sum int
	var result int
	length := len([]rune(S))

	for bit := 0; bit < (1 << (length - 1)); bit++ {
		for i := 0; i < length-1; i++ {
			if (bit>>i)&1 == 1 {
				num, err := strconv.Atoi(S[start : i+1])
				if err != nil {
					fmt.Println(err)
				}
				sum += num
				start = i + 1
			}
		}
		num, _ := strconv.Atoi(S[start:length])
		result += sum + num
		start, sum = 0, 0
	}
	fmt.Println(result)
}
//  [ruby]
s = gets.chomp
@ans = 0
def dfs(s,sum,count)
  if s.size == count 
    sum += s.to_i
    @ans += sum 
  else
    dfs(s,sum,count+1)
    dfs(s[count..-1],sum + s[0..count-1].to_i,1)
  end
end 

puts dfs(s,0,1)
//  [ruby]
s = gets.chomp.to_i
num = s.to_s.split("").map(&:to_i)
sum = 0
 
n = num.length
(1..n).each do |digit| #桁数
    (0..n-1).each do |i| #インデックス
        next if digit > (n-i)
        dig = num[i] * 10**(digit-1)
        left = i
        right = (n-1 - (i+digit) > 0 ? n-1 - (i+digit): 0)
        sum += dig * (2 ** (left + right))
    end
end
puts sum
//  [ruby]
s = gets.chomp.to_i
num = s.to_s.split("").map(&:to_i)
sum = 0

n = num.length
(1..n).each do |digit| #桁数
    (0..n-1).each do |i| #インデックス
        next if digit > (n-i)
        dig = num[i] * 10**(digit-1)
        left = i
        right = (n-1 - (i+digit) > 0 ? n-1 - (i+digit): 0)
        sum += dig * (2 ** (left + right))
    end
end
puts sum
//  [ruby]
result=[]
n=gets.chomp.to_s
len=n.length-1

for i in 0..(2**len)-1
    plus=Array.new(len,0)
    ans=[]

    i=i.to_i
    for j in 0..len-1
       
        if (i&(1<<j))!=0
         plus[j]="+"
         else
         next
         end
    end
    
    for k in 0..n.length-1
    ans<<n[k]
    if plus[k]=="+"
    ans<<plus[k]
    end

    end
    
    
    result<<ans
end

answer=0

for i in 0..result.length-1
    v=0
    check=0
    for j in 0..result[i].length-1
    
        if result[i][j]=="+"
            v+=check.to_i
            check=0
        else
        check="#{check}#{result[i][j]}"
        end
    end
    if check!=0
        v+=check.to_i
    end

    answer+=v
end
p answer
//  [ruby]
S=gets.chomp

sum = 0
['+',''].repeated_permutation(S.length-1) do |t|
    sum += eval(S.chars.zip(t).join)
end

puts sum
//  [ruby]
s = gets.chomp
sum_all = 0
(2**(s.size-1)).times do |cmb|
  sum = 0
  x = 0
  s.each_char do |c|
    x = x*10 + c.to_i
    if (cmb & 1) == 1
      sum += x
      x = 0
    end
    cmb >>= 1
  end
  sum_all += sum + x
end
p sum_all
//  [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() {
    arc061_c();
}

fn arc061_c() {
    input! {
        s: u64
    }
    let n = (s as f64).log10().floor() as u32;
    let mut sum = 0 as u64;
    for i in 0..(2 as u32).pow(n) {
        sum += arc061_c_helper(i, s)
    }
    println!("{}", sum);
}

fn arc061_c_helper(bits: u32, n: u64) -> u64 {
    let mut bits = bits;
    if bits == 0 {
        return n;
    } else {
        let mut i = 0 as u32;
        while bits % 2 == 0 {
            i += 1;
            bits /= 2
        }
        bits = bits / 2;
        let shift = (10 as u32).pow(i+1) as u64;
        return n % shift + arc061_c_helper(bits, n / shift);
    }
}
//  [rust]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

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

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let S: Vec<char> = sc.chars();
    let N = S.len();
    let mut ans = 0;
    for bit in 0..1<<(N-1) {
        let mut num = (S[0] as u8 - b'0') as usize;
        for i in 0..N-1 {
            if (bit>>i) & 1 != 0 {
                ans += num;
                num = (S[i+1] as u8 - b'0') as usize;
            } else {
                num = num * 10 + (S[i+1] as u8 - b'0') as usize;
            }
        }
        ans += num;
    }
    println!("{}", ans);
}
//  [rust]
use std::io::{stdout, BufWriter, Write};

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! {
        ss: String,
    }
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let s = ss
        .chars()
        .map(|c| c.to_digit(10).unwrap() as i64)
        .collect::<Vec<_>>();
    if s.len() == 1 {
        writeln!(out, "{}", s[0]);
        return;
    }
    let mut ans = 0;
    for i in 0..1 << (s.len() - 1) as u32 {
        let mut sum = 0;
        sum += s[0];
        for k in 0..s.len() - 1 {
            if (i >> k & 1) == 0 {
                sum *= 10;
                sum += s[k + 1];
            } else {
                ans += sum;
                sum = s[k + 1];
            }
        }
        ans += sum;
    }
    writeln!(out, "{}", ans);
}
//  [rust]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed 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 s:String = read();
    let c:Vec<char> = s.chars().collect();
    let mut cnt = 0u128;
    for bit in 0..1<<(s.len()-1) {
        let mut tmp = 0u128;
        for i in 0..s.len()-1 {
            tmp *= 10;
            tmp +=  c[i].to_digit(10).unwrap() as u128;
            if bit & 1<<i == 1 <<i {
                cnt += tmp;
                tmp = 0;
            }
        }
        tmp *= 10;
        tmp += c[s.len()-1].to_digit(10).unwrap() as u128;
        cnt += tmp;
    }
    println!("{}", cnt);
}
//  [rust]
use proconio::{input, fastout};

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

    let mut ans = 0;

    for merge in 0..2usize.pow(s.len().saturating_sub(1) as u32) {
        let mut num_string = String::new();
        for i in 0..s.len() {
            num_string.push(s.chars().nth(i).unwrap());
            if merge & (1usize << i)  == 0 {
                // println!("{} {:?}", merge, num_string);
                ans += num_string.parse::<u64>().unwrap_or(0);
                num_string = "".to_string();
            }
        }
        ans += num_string.parse::<u64>().unwrap_or(0);
    }

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

use text_io::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let mut a:String = read!();
    let vv:Vec<char> = a.chars().collect_vec();
    let mut v:Vec<usize> = Vec::new();
    for i in 0..vv.len() {
        if vv[i]=='0' {v.push(0) }
        if vv[i]=='1' {v.push(1) }
        if vv[i]=='2' {v.push(2) }
        if vv[i]=='3' {v.push(3) }
        if vv[i]=='4' {v.push(4) }
        if vv[i]=='5' {v.push(5) }
        if vv[i]=='6' {v.push(6) }
        if vv[i]=='7' {v.push(7) }
        if vv[i]=='8' {v.push(8) }
        if vv[i]=='9' {v.push(9) }
    }
    let mut s:usize = 0;
    for i in 0..1<<(v.len()-1) {
        let mut c:usize = 1;
        for j in 0..v.len() {
            s += c*v[v.len()-j-1];
            if (i>>j)%2==0 {
                c*=10;
            }
            else {
                c=1;
            }
        }
    }
    println!("{}",s);
}
//  [swift]
// 蟻本: 例題 2-1-1　部分和問題 の類題
/*
 与えられたのが 1234 のときは
 1234,
 1 +234, 1 +2 +34, 1 +2 +3 +4,
 12 +34, 12 +3 +4,
 123 +4
 の合計が聞かれてる
 ↑を
 [1] 234, [1, 2] 34, [1, 2, 3] 4
 [12] 34, [12, 3] 4,
 [123] 4
 のように+で区切り終えたものを配列で管理し,
 まだ+で区切る余地のあるものを文字列で扱いました(ノ)>◡<(ヾ)ﾓﾁﾓﾁ
 */

func dfs(_ s: String) {
    if s.count==0 { return }    // ベースケース(・・？) (文字列が空("")なら終了)
    
    for i in 1..<s.count {
        let idx: String.Index = s.index(s.startIndex, offsetBy: i)  // +で区切る場所を指定
        seq.append(Int(s[..<idx])!) // +で区切り終わった部分を記憶
        res += seq.reduce(0, +) + Int(s[idx...])!   // 計算, .reduce(0, +)で配列の和を計算できる
        
        
        dfs(String(s[idx...]))  // 再帰呼び出し
        seq.removeLast()
    }
}

let S: String = readLine()!
var seq: [Int] = []
var res = Int(S)!

dfs(S)  // 再帰スタート٩(๑❛ᴗ❛๑)۶
print(res)  // (๑•ૅㅁ•๑)
//  [swift]
// 蟻本: 例題 2-1-1　部分和問題 の類題
/*
 与えられたのが 1234 のときは
 1234,
 1 +234, 1 +2 +34, 1 +2 +3 +4,
 12 +34, 12 +3 +4,
 123 +4
 の合計が聞かれてる
 ↑を
 [1] 234, [1, 2] 34, [1, 2, 3] 4
 [12] 34, [12, 3] 4,
 [123] 4
 のように+で区切り終えたものを配列で管理し,
 まだ+で区切る余地のあるものを文字列で扱いました(ノ)>◡<(ヾ)ﾓﾁﾓﾁ
 */

func dfs(_ s: String) {
    if s.count==0 { return }    // ベースケース(・・？) (文字列が空("")なら終了)
    
    for i in 1..<s.count {
        let idx: String.Index = s.index(s.startIndex, offsetBy: i)  // +で区切る場所を指定
        seq.append(Int(s[..<idx])!) // +で区切り終わった部分を記憶
        res += seq.reduce(0, +) + Int(s[idx...])!   // 計算, .reduce(0, +)で配列の和を計算できる
        
        dfs(String(s[idx...]))  // 再帰呼び出し
        seq.removeLast()
    }
}

let S: String = readLine()!
var seq: [Int] = []
var res = Int(S)!

dfs(S)  // 再帰スタート٩(๑❛ᴗ❛๑)۶
print(res)  // (๑•ૅㅁ•๑)
//  [typescript]
declare function require(x: string): any;

var input = require("fs").readFileSync("/dev/stdin", "utf8");
input = input.split("\n");

const s = input.shift();
const n = s.length;

let dp:Array<Array<number>> = [];
for(let i=0; i<n; i++){
	dp[i] = [];
}

for(let i=0; i<n; i++){
	for(let ii=i; ii<n; ii++){
		if(ii == i){
			dp[i][ii] = +s[ii];
		}
		else{
			dp[i][ii] = dp[i][ii-1]*10 + (+s[ii]);
		}
	}
}

let result = 0;

const lim = 1<<(n-1);
for(let b=0; b<lim; b++){
	let l = 0;
	for(let i=0; i<n; i++){
		if(b & 1<<i){
			result += dp[l][i];
			l = i+1;
		}
		else if(i==n-1){
			result += dp[l][i];
		}
	}
}

console.log(result);
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};const sum=(arr)=>{return arr.reduce((a,b)=>a+b);};
const main=()=>{
  let s=ts(),n=s.length,ans=0
  for(let i=0;i<2**(n-1);i++){
    let ss=s.split('')
    for(let j=0;j<n-1;j++){
      if(i&1<<j)ss[j]+='+'
    }
    ans+=eval(ss.join(''))
  }
  to(ans)
}
main()
//  [python]
a, b = map(int, input().split())
ans = a
if b < a:
    ans -= 1
print(ans)
//  [python]
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

a, b =  map(int, sys.stdin.readline().split())

if b < a:
    print(a - 1)
else:
    print(a)
//  [python]
import numpy as np
a,b = map(int,input().split())
ans = 0
for i in range(1,13):
    if i < a:
        ans += 1
    elif i == a:
        if i <= b:
            ans += 1

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


public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    //Split by '' and Convert String Array to Int Array
    int[] inputArray = Stream.of(line.split(" ")).mapToInt(Integer::parseInt).toArray();
    final int MONTH = inputArray[0];
    final int DAY = inputArray[1];
    int countTakahashi = 0;

    if (DAY >= MONTH){
      countTakahashi = MONTH;
    } else if (DAY < MONTH){
      countTakahashi = MONTH - 1;
    }

    System.out.print(countTakahashi);

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int result = a - 1;
        if (a <= b) result = a;
        
        System.out.println(result);
    }
}
//  [java]
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans = a;
    if(a > b) ans--;
    System.out.println(ans);
  }
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   int a, b;
   cin >> a >> b;
   int ans = 0;
   if (a <= b) {
      ans = a;
   } else {
      ans = a-1;
   }
   cout << ans << endl;

   return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
int a,b,x=1,y,n=2,m;
int main()
{
    cin>>a>>b;
    while (n!=(a+1)&&a!=1&&n<13)
    {
        if (n<=b&&n==a)
            x++;
        else if (n!=a)
            x++;
        n++;
    }
    cout<<x;
    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define maxn 1000005

int main() {
    int n, m;
    while(~scanf("%d %d", &n, &m)) {
        if(n <= m) cout << n << endl;
        else cout << n - 1 << endl;
    }
    return 0;
}
//  [c]
#include <stdio.h>
int main(void){
    int a, b;
    scanf("%d%d", &a, &b);
    if(a > b){
        printf("%d", a - 1);
    }else{
        printf("%d", a);
    }
    
}
//  [c]
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long
#define pai 3.1415926535897932384626433832795028841971693

int main(){
 int a,b;
 scanf("%d %d",&a,&b);
 if(a<=b){
   printf("%d",a);
 }
  else{
    printf("%d",a-1);
  }
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  printf("%d\n",a+(a>b ? -1 : 0));
  return 0;
}
//  [javascript]
function Main(input){
	input=input.split(/\n|\s/);
	input.forEach(function(e,i,a){a[i]=Number(a[i]);});
	
	ans=input[0];
	if(input[0]>input[1]){ans--;}
	
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));