#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n';
#define all(x) (x).begin(),(x).end()
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    ll r = 0;
    ll ans = 0;
    for(int i=0;i<n;i++){
        chmax(r,i+1);
        if(s[i] != t[i]){
            while(r<n && s[r] == '0')r++;
            if(r == n){
                cout << -1 << endl;
                return 0;
            }
            ans += r - i;
            s[r] = '0';
            s[i] = t[i];
        }
    }
    cout << ans << endl;

}

#include <bits/stdc++.h>
using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = i + 1;
  }
  sort(begin(a), end(a));
  string ans = "Yes";
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))
#define PB            push_back

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using V = vector<int>;

template<typename T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T = int> T inline input() { T x; cin >> x; return (x); }
template<typename T> void inline print(T& x) { cout << x << '\n'; }

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);

  int N,M;
  cin >> N >> M;
  V A(N);
  REP(i,N) cin >> A[i];

  map<int,int> cnt;
  set<int> s;
  EACH(i,0,N) {
    s.insert(i);
  }

  int ans = INF;
  REP(i,M) {
   int a = A[i];
   cnt[a]++;
   s.erase(a);
  }

  chmin(ans, *s.begin());
  REP(i,N-M) {
    int aleft = A[i];
    int aright = A[i+M];
    cnt[aleft]--;
    if (cnt[aleft] == 0) s.insert(aleft);
    cnt[aright]++;
    s.erase(aright);
    chmin(ans, *s.begin());
  }

  print(ans);
}

#include <cstdio>
const int maxn = 1.5e6+5;
inline int min(int a,int b){return a<b?a:b;}
int n,m,a[maxn],cnt[maxn],mex[maxn<<2],ans=1919810;
void build(int k,int l,int r){
	if(l == r)return mex[k]=l,void();
	int mid = l+r>>1;
	build(k<<1,l,mid),build(k<<1|1,mid+1,r),mex[k] = min(mex[k<<1],mex[k<<1|1]);
}
void insert(int k,int l,int r,int p,int v){
	if(l == r){
		if(v)++cnt[l],(cnt[l]==1?mex[k]=1919810:0);
		else --cnt[l],(cnt[l]==0?mex[k]=l:0);
		return ;
	}
	int mid = l+r>>1;
	p<=mid?insert(k<<1,l,mid,p,v):insert(k<<1|1,mid+1,r,p,v);
	mex[k] = min(mex[k<<1],mex[k<<1|1]);
}
int main(){
	scanf("%d %d",&n,&m),build(1,1,n+1);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]),++a[i];
	for(int i=1;i<=m;++i)insert(1,1,n+1,a[i],1);
	ans=min(ans,mex[1]);
	for(int i=m+1;i<=n;++i)insert(1,1,n+1,a[i-m],0),insert(1,1,n+1,a[i],1),ans=min(ans,mex[1]);
	printf("%d\n",ans-1);
	return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int h, w;
bool used[16][16];

ll dfs(int i, int j, int a, int b){
    if(j>=w) j=0, i++;
    if(i==h) return 1;
    if(a<0 || b<0) return 0;
    if(used[i][j]) return dfs(i,j+1, a, b);
    ll res = 0;
    used[i][j] = true;
    // 次に置く
    res += dfs(i, j+1, a, b-1);
    // 横に置く
    if(j+1<w && !used[i][j+1]){
        used[i][j+1] = true;
        res += dfs(i, j+1, a-1, b);
        used[i][j+1] = false;
    }
    // 縦に置く
    if(i+1<h && !used[i+1][j]){
        used[i+1][j] = true;
        res += dfs(i, j+1, a-1, b);
        used[i+1][j] = false;
    }
    used[i][j] = false;
    return res;
}

int main()
{
    int a, b;
    cin >> h >> w >> a >> b;

    ll ans = dfs(0, 0, a, b);

    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef vector<bool> VB;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) LL((a).size())

#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define ROF(i,a,b) for(LL i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL LARGE_INT = 1e9+100;
const LL INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const LL MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    LL k;cin>>k;

    LL result = 0;
    FOR(i,1,k+1){
        LL now = k/i;
        for(LL j=1;j*j<=now;j++){
            LL sum = 0;
            if(now==1){
                result++;
            }
            else{
                sum = 1;
                sum +=  (now/j-j) * 2;
                result += sum;
            }
        }
    }

    cout<<result<<endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}


#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-10;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll dp[2][50001][3];

int main(){
	int n; cin >> n;
	vl a(n), b(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	priority_queue<ll> pq0, pq1;
	ll ans = 0;
	rep(i,n){
		if(i & 1) pq1.push(a[i] - b[i]);
		else pq0.push(a[i] - b[i]);
		ans += b[i];
	}
	rep(i,n/2){
		ll s = pq1.top(); pq1.pop();
		ll t = pq0.top(); pq0.pop();
		if(s+t < 0) break;
		ans += s+t;
	}
	cout << ans << "\n";
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>

using namespace std;

#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define reverseall(x) reverse(all(x))
#define to_upper(x) transform(x.begin(), x.end(), x.begin(), ::toupper)
#define to_lower(x) transform(x.begin(), x.end(), x.begin(), ::tolower)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORS(i,s,n) for(int i=s;i<n;i++)
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "= " << x << ", " << #y << "= " << y << endl
#define clr(x) memset(x, 0, sizeof(x))
#define gcd __gcd
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
typedef priority_queue<int, vi, greater<int>> minpq;
typedef priority_queue<ll, vi, greater<ll>> minpql;
const int mod = 1000000007;
const double eps = 1e-14;
void YES(bool t = 1) { const string YESNO[2] = {"NO", "YES"};cout << YESNO[t] << endl; }
void Yes(bool t = 1) { const string YesNo[2] = {"No", "Yes"};cout << YesNo[t] << endl; }
void yes(bool t = 1) { const string yesno[2] = {"no", "yes"};cout << yesno[t] << endl; }
inline bool isPowerOfTwo(ll x) { return x && (!(x&(x-1))); }
ll mpow(int b, int e, int modu=0) {
    ll result = 1,base = b, exp = e;
    if(modu) base %= mod;
    while (exp > 0) {
        if (exp & 1){
            result = ((ll)result * base) ;
            if(modu) result %= mod;
        }
        base = ((ll)base * base);
        if(modu) base %= mod;
        exp >>= 1;
    }
    return result;
}
// int64_t bpow(int b, int e){
//     int64_t result = 1,base = b, exp = e;
//     while (exp > 0) {
//         if (exp & 1){
//             result = ((int64_t)result * base) ;
//         }
//         base = ((int64_t)base * base);
//         exp >>= 1;
//     }
//     return result;
// }
// bool isPerfectSquare(long double x){long double sr = sqrt(x); return ((sr - floor(sr)) == 0);}
// bool isIn(string &s2, string &s1){if (s1.find(s2) != string::npos) return true;return false;}
// bool isSorted(vi &arr){for(int i=0;i<(int)arr.size()-1;i++) if(arr[i] > arr[i+1]) return false;return true;}
void print_v(vi &arr){for(auto x: arr) cout << x <<',';cout << "\n";}

int TEST_CASES = 0;
void submain(){
    long double x,y,r;
    cin >> x >> y >> r;
    ll ans = 0;
    r += eps;
    for(int i=floor(x-r);i<=ceil(x+r);i++){
        // deb(i);
        long double val = r*r-(i-x)*(i-x);
        if(val >= 0){
            val = sqrt(val);
            long double vala = floor((long double)val+y);
            long double valb = ceil((long double)y-val);
            // deb2(vala, valb);
            ans += (vala-valb+1);
        }
    }
    cout << ans << '\n';
}

int main()
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    send help
    if(TEST_CASES){
        int t;
        cin >> t;
        while(t--){
            submain();
        }
    }else{
        submain();
    }
	return 0;
}


// #pragma GCC optimize(3,"Ofast","inline")
// #pragma GCC optimize(2)
// #pragma GCC optimize("-Ofast","-funroll-all-loops")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <cstdlib>
#include <bitset>
#include <assert.h>
#include <time.h>
#include <iomanip>
#include <functional>
#include <unordered_map>
#include <unordered_set>
// #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
// char buf[(1 << 21) + 1], * p1 = buf, * p2 = buf;
// #define int long long
#define lowbit(x) (x & (-x))
#define lson root << 1, l, mid
#define rson root << 1 | 1, mid + 1, r
typedef unsigned long long ull;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> VI;
#define rg register
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define SZ(x) ((int)((x).size()))
#define bug puts("BUG")
#define ALL(x) x.begin(),x.end()
const long long INF = 2e18; //0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-10;
void err(){puts("");}
template<typename T,typename... Args>void err(const T& arg,const Args&... args){
    std::cout << arg << ' ';
    err(args...);
}
template<typename T> void read(T &x){
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
template<typename T, typename... Args> void read(T &first, Args& ... args) {
    read(first);
    read(args...);
}
template<typename T>void chmax(T& a,T b){
    if (b > a)
        a = b;
}
template<typename T>void chmin(T& a,T b){
    if (b < a)
        a = b;
}
#ifdef LOCAL
#define dbg(x...) do{std::cout<<#x<<" -> ";err(x);}while(0)
FILE *_INPUT = freopen("input.txt", "r", stdin);
// FILE *_OUTPUT = freopen("output.txt", "w", stdout);
#else
#define dbg(x...) ;
#endif
using namespace std;
const int maxn = 2e5 + 10;
const int DEG = 20;
int fa[maxn][20];
int deep[maxn], son[maxn], len[maxn];
vector<int> G[maxn];
int lca(int u,int v)
{
    if (deep[u] < deep[v])
        swap(u, v);
    int x = deep[u] - deep[v];
    for (int i = 0; i < DEG && x; ++i)
    {
        if (x & 1)
            u = fa[u][i];
        x >>= 1;
    }
    if (u == v)
        return u;
    for (int i = 0; i < DEG; ++i)
    {
        if (fa[u][i] == fa[v][i])
            continue;
        u = fa[u][i];
        v = fa[v][i];
    }
    return fa[u][0];
}

void dfs(int u, int pre)
{
    son[u] = 0;
    len[u] = 0;
    deep[u] = deep[pre] + 1;
    fa[u][0] = pre;
    for (int i = 1; i < DEG; ++i)
    {
        fa[u][i] = fa[fa[u][i - 1]][i - 1];
    }
    for (int v : G[u])
    {
        if (v == pre)
            continue;
        dfs(v, u);
        len[u] = max(len[u], len[v] + 1);
        if (len[v] > len[son[u]])
            son[u] = v;
    }
}
ll ans[maxn];
int las = 0;
void dfs2(int u, int pre)
{
    ans[u] = ans[las] + deep[u] + deep[las] - 2 * deep[lca(u, las)];
    las = u;
    for (int v : G[u])
    {
        if (v == pre || v == son[u])
            continue;
        dfs2(v, u);
    }
    if(son[u])
        dfs2(son[u], u);
}

int main()
{
    int n;
    int u, v;
    read(n);
    for (int i = 1; i < n; ++i)
    {
        read(u, v);
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    dfs(1, 0);
    int R = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (deep[i] > deep[R])
            R = i;
    }
    dfs(R, 0);
    dfs2(R, 0);
    for (int i = 1; i <= n; ++i)
        printf("%lld%c", ans[i], " \n"[i == n]);
}

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;
int n;
vc<vc<int>> e;

pair<int, int> farthest(int i, int par = -1){
    pair<int, int> ret {0, i};
    for(const int &j : e[i]){
        if(j == par) continue;
        auto next = farthest(j, i);
        next.first ++;
        Maxi(ret, next);
    }
    return ret;
}

vc<int> longest(int s, int t, int par = -1){
    if(s == t) return {s};
    for(const int &i : e[s]){
        if(i == par) continue;
        auto p = longest(i, t, s);
        if(!p.empty()){
            p.push_back(s);
            return p;
        }
    }
    return {};
}

vc<int> ans;
vc<int> path;
int v = 1;
void assign(int i, int depth = 0, int par = -1){
    ans[i] = v;
    for(const int &j : e[i]){
        if(j == par || (depth != -1 && j == path[depth+1])) continue;
        v ++;
        assign(j, -1, i);
        v ++;
    }
    if(depth != -1 && depth < path.size()-1){
        v ++;
        assign(path[depth+1], depth+1, i);
        // v ++;
    }
}

int main(){
    cin >> n;
    e = vc<vc<int>>(n);
    ans = vc<int>(n);

    Rep(n-1){
        Cin(int, a, b); a--, b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    int s = farthest(0).second;
    int t = farthest(s).second;
    path = longest(t, s);
    assign(s);
    Couts(ans);
}


//* Jai shree Ram
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lld                                 long double
#define ll                                  long long
#define FOR(i,a,b)                          for(int i=(a);i<(b);i++)
#define vi                                  vector<int>
#define vll                                 vector<ll>
#define all(a)                              (a).begin(),(a).end()
#define sz(a)                               (int)a.size()
#define pb                                  push_back
#define ppb                                 pop_back
#define pf                                  push_front
#define fr                                  first
#define sc                                  second
#define uniq(v)                             (v).erase(unique(all(v)),(v).end())
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

void __print(int x) {cerr << x;}void __print(long x) {cerr << x;}void __print(long long x) {cerr << x;}void __print(unsigned x) {cerr << x;}void __print(unsigned long x) {cerr << x;}void __print(unsigned long long x) {cerr << x;}void __print(float x) {cerr << x;}void __print(double x) {cerr << x;}void __print(long double x) {cerr << x;}void __print(char x) {cerr << '\'' << x << '\'';}void __print(const char *x) {cerr << '\"' << x << '\"';}void __print(const string &x) {cerr << '\"' << x << '\"';}void __print(bool x) {cerr << (x ? "true" : "false");}template<typename T, typename V>void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}void _print() {cerr << "]\n";}template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
// __builtin_popcountll(x);
// __builtin_clz(x) // Count Leading zeros
// __builtin_ctz(x) // Trailing zeros
const int MM = 998244353;
const int mod = 1e9 + 7;
const int INF = 1e9 + 5;
const int N = 1e5 + 5;

/* Common Mistakes By Me
  * make sure to read the bottom part of question
  * special cases (n=1?)
  * In Game Theory Check your solution and consider all the solutions
  * Always initialise value to the declare array in local scope
  * don't use debugs in interactive problems
*/

void solve()
{
    lld a,b;
    cin >> a >> b;
    cout << a*b/100 << "\n";
}

signed main()
{
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t;
    t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
}

#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
	return x*f;
}
long double a,b;
int main()
{
	cin>>a>>b;
	cout<<a*b*0.01;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

template <int mod> struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int) (1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

template <typename T> T power(T a, long long n) {
    T r = 1;
    while(n > 0){
        if(n & 1) r *= a;
        a *= a;
        n >>= 1;
    }
    return r;
}

const int mod = int(1e9) + 7;
using mint = ModInt<mod>;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int N, P; cin >> N >> P;
    mint ans = P - 1;
    ans *= power(mint(P-2), N-1);
    cout << ans << '\n';
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using pii = pair<int, int>;

int main() {
    cin.tie(0); ios::sync_with_stdio(0);
    LL n, p; cin >> n >> p;
    if (p == 2) {
        cout << (n==1 ? 1 : 0) << endl;
        return 0;
    }
    LL res = 1, top = n-1, base = p-2, mod = 1e9+7;
    while (top) {
        if (top & 1) res = res*base%mod;
        base = base*base%mod;
        top >>= 1;
    }
    res = res*(--p)%mod;
    cout << res << endl;

}


#include<iostream>
#include<cstdio>
#include<cstring>
typedef long long ll;
typedef unsigned un;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
ll read()
{
	ll f=1,x=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
	return f*x;
}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
bool umin(int& a,int t){if(t<a)return a=t,1;return 0;}
bool umin(ll& a,ll t){if(t<a)return a=t,1;return 0;}
bool umax(int& a,int t){if(t>a)return a=t,1;return 0;}
bool umax(ll& a,ll t){if(t>a)return a=t,1;return 0;}

#define MAXN 511
bool a[MAXN][MAXN];
char s[MAXN];
int main()
{
	int n=read();
	for(int i=1;i<=n;++i)
	{
		scanf("%s",s+1);
		for(int j=1;j<=n;++j)a[i][j]=(s[j]=='1');
		a[i][i]=1;
	}
	for(int k=1;k<=n;++k)
		for(int i=1;i<=n;++i)
			for(int j=1;j<=n;++j)a[i][j]|=(a[i][k]&a[k][j]);
	double ans=0;
	for(int u=1;u<=n;++u)
	{
		int c=0;
		for(int s=1;s<=n;++s)c+=a[s][u];
		ans+=1.00/c;
	}
	printf("%.11lf\n",ans);
	return 0;
}

// Coder: @SumitRaut
#include <bits/stdc++.h>
#define speedup ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr),cout.precision(16)
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
#define sbc __builtin_popcount
#define pb push_back
#define em emplace
#define emb emplace_back
#define ff first
#define ss second
#define ll long long
const ll mod = 1e9+7;

template<typename T> void smax(T& a, T b) { if(a<b) a=b; }
template<typename T> void smin(T& a, T b) { if(a>b) a=b; }
template<typename T> T pw(T a,T b) { T p=1,one=1; while(b) { if(b&one) p=p*a; a=a*a; b >>=1; } return p; }
template<typename T> T pwm(T a,T b,T md=mod) { T p=1,one=1; while(b) { if(b&one) p=p*a%md; a=a*a%md; b >>=1; } return p; }

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
	for(auto& it:v)
		is>>it;
	return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto &it : v)
		os << it << ' ';
	return os;
}

#ifndef ONLINE_JUDGE
class Timer { chrono::high_resolution_clock::time_point start_t, end_t; public: Timer() { start_t=chrono::high_resolution_clock::now(); } ~Timer() { end_t = chrono::high_resolution_clock::now(); auto duration = chrono::duration_cast<chrono::milliseconds>(end_t-start_t); cerr<<"\nRunTime: "<<duration.count()<<"ms"<<'\n'; } };
void debug() { cerr << '\n'; }
template <typename T, typename... Args>
void debug(T print, Args... args) { cerr << ' ' << print; debug(args...); }
#define deb(...) cerr << "[" << #__VA_ARGS__ << "]" << " --> ", debug(__VA_ARGS__)
#else
#define deb(...) void(0)
#endif

const int inf=1e8;
vector<int> cnt;
void bfs(int v, vector <int> &d, vector<vector<int>>& g) {
    queue<int> Qu;
    Qu.push(v);
    d[v] = 0;
    while (!Qu.empty()) {
        auto tmp = Qu.front();
        Qu.pop();
        ++cnt[tmp];
        for (auto &it:g[tmp]) {
            if (d[it] == inf) {
                d[it] = d[tmp] + 1;
                Qu.push(it);
            }
        }
    }
}

void solve() {
	int n;
	cin>>n;
	vector<vector<int>> g(n);
	cnt.assign(n,0);
	for(int i=0;i<n;++i) {
		string s;
		cin>>s;
		for(int j=0;j<n;++j)
			if(s[j]=='1')
				g[i].pb(j);
	}
	for(int i=0;i<n;++i) {
		vector<int> d(n,inf);
		bfs(i,d,g);
	}
	double ans=0.0;
	for(auto& it:cnt)
		ans+=1.0/it;
	cout<<ans<<endl;
}

int main() {
	#ifndef ONLINE_JUDGE
	Timer timer;
	#endif
	speedup;
	//int t; cin>>t; while(t--)
	solve();
}


/*---------------------------------------
   BISMILLAHIR RAHMANIR RAHIM
   AUTHOR : Md. Sajjat Hossen
   TIME : 20-March,2021 10:10:41 PM
----------------------------------------*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef  long long               ll;
typedef  long double             ld;
typedef  unsigned long long      ull;
typedef  pair<int, int>          pii;
typedef  pair<ll, ll>            pll;
typedef  vector<int>             vi;
typedef  vector<ll>              vll;
typedef  tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds_set;
typedef  tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> pbds_multiset;

inline int Int() { int x; scanf("%d", &x); return x; }
inline ll Long() { ll x; scanf("%lld", &x); return x; }

int dx[8] = { 0, -1, 0, 1, -1, -1, 1, 1 };
int dy[8] = { -1, 0, 1, 0, -1, 1, 1, -1 };

const int N       = (int) 2e5 + 5;
const int mxN     = (int) 1e6 + 6;
const ll MOD      = (ll) 1e9 + 7;

#define    debug(x)    cerr << #x << " = " << x << '\n';
#define    all(x)      x.begin(), x.end()
#define    szof(x)     (int) x.size()
#define    ff          first
#define    ss          second
#define    pb          push_back
#define    mp          make_pair
#define    PI          acos(-1.0)
#define    TN          typename
#define    nl          '\n'
#define    Fast_IO     ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

template <TN T> T gcd(T a, T b) { return !b ? a : gcd(b, a % b); }
template <TN T> T lcm(T a, T b) { return a * (b / gcd(a, b)); }

int checkdigit(ll n) {
	int res = 0;
	while (n) {
		res++;
		n /= 10;
	}
	return res;
}

bool checkEqual(ll n, int t) {
	//debug("yes")
	string s1 = "", s2 = "";
	int i = 1;
	while (n) {
		if (i <= t) s1 += ((n % 10) + '0');
		else s2 += ((n % 10) + '0');
		n /= 10;
		i++;
	}
	return (s1 == s2) ? 1 : 0;
}

int main() {
    //Fast_IO
    //clock_t tStart = clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int test = 1, tc = 0;
    while (test--) {
        ll n = Long();
        int k = checkdigit(n);
        int i = 1, ans = 0;
        while (1) {
        	int digit = checkdigit(i);
        	ll x = i * pow(10, digit) + i;
        	//debug(x)
        	if (x > n) break;
        	if (checkEqual(x, digit)) {
        		//debug(x);
        		ans++;
        	}
        	++i;
        }
        printf("%d\n", ans);
    }
    //fprintf(stderr, "\nRuntime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    return 0;
}

//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>
#include<fstream>
#include<array>
#include<assert.h>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 +7;

const double EPS = 1e-9;

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

	int N, K;
	cin >> N >> K;

	string S;
	cin >> S;

	map<char, int> cmap;
	cmap['R'] = 0;
	cmap['S'] = 1;
	cmap['P'] = 2;

	char jan[3][3]=
	{
		{'R','R','P'},
		{'R','S','S'},
		{'P','S','P'}
	};

	rep(i, 0, K)
	{
		string T;
		if (SZ(S) % 2 == 1)
		{
			S += S;
		}
		rep(i, 0, SZ(S))
		{
			if (i % 2 == 1)continue;
			T += jan[cmap[S[i]]][cmap[S[i + 1]]];
		}
		S = T;
	}

	cout << S[0] << endl;

	return 0;
}


///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define        u64             uint64_t
#define        ll              long long
#define        endl            "\n"
#define        PI              acos(-1)
#define        fi              first
#define        si              second
#define        mkp             make_pair
#define        pb              push_back
#define        set0(arr)       memset(arr, 0, sizeof(arr))
#define        setinf(arr)     memset(arr, 126, sizeof(arr))
#define        gcd(a,b)        __gcd(a,b)
#define        lcm(a,b)        (a*b)/gcd(a,b)
#define        all(x)          (x).begin(),(x).end()
#define        sz(v)           ((ll)(v).size())
#define        mem(a,b)        memset(a, b, sizeof(a))
#define        uniq(v)         (v).erase(unique(all(v)),(v).end())
#define        mchk(mask,pos)  (mask & (1<<pos))
#define        mset(mask,pos)  (mask bitor (1<<pos))
#define        munset(mask,pos) (mask ^ (1<<pos))
#define        IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
using          pll        =      pair<ll, ll> ;
using          vl         =      vector<ll> ;
using          vpll       =      vector<pll> ;
using          mll        =      map<ll, ll> ;
using          mcl        =      map<char, ll> ;
using          msl        =      map<string,ll> ;
using          sl         =      set<ll> ;
using          sc         =      set<char> ;
using          dl         =      deque<ll> ;
const int N = 1e6+5 ;

const int mod = (int)  1e9 + 7;
vl      adj[N] ;
vpll    adjc[N] ; // Only for this N can't be greater than 1e6+5;segmentation fault;
ll      vis[N] ;
ll      arr[N] ;

ll sumd(ll a,ll b){return (((a%mod)+(b%mod))%mod);}
ll muld(ll a,ll b){return (((a%mod)*(b%mod))%mod);}
ll subd(ll a,ll b){return (((a%mod)-(b%mod)+mod)%mod);}
bool chk(ll ii,ll jj,ll nn,ll mm){if((0<=ii&&ii<nn)&&(0<=jj&&jj<mm)) return true;else return false;}

int main()
{
    IOS;
    ll a, b, c, d, n, m, p, x, y, z, i, j, k, f = 0, tc, cnt = 0, sum = 0, mul = 1, mi, ma, cs;
    string   str ;
    char     ch ;
    double   db ;
    ll       l, r ;
    //code

    cin>>tc;
    for(cs=1;cs<=tc;cs++)
    {
        cin>>n;
        string str1,str2,str3;
        cin>>str1>>str2>>str3;
        for(i=0;i<n;i++)
        {
                cout<<1;
        }
        for(i=0;i<n;i++)
        {
               cout<<0;
        }
        cout<<1;
        cout<<endl;

    }

    //code
    return 0;
}

#define TO_BE_SUBMITTED
#include <bits/stdc++.h>
// #include <atcoder/fenwicktree>
// #include <atcoder/segtree>
// #include <atcoder/lazysegtree>
// #include <atcoder/string>
// #include <atcoder/math>
// #include <atcoder/convolution>
// #include <atcoder/modint>
// #include <atcoder/dsu>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/scc>
// #include <atcoder/twosat>

namespace atcoder{};
using namespace atcoder;
using namespace std;

#define fr first
#define sc second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (n); i >= 1; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define snuke srand((unsigned)clock() + (unsigned)time(NULL));
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<P>;
using vlp = vector<LP>;
inline int getInt()
{
    int x;
    scanf("%d", &x);
    return x;
}
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

ll a, b, c, d;

bool ok(ll x){
    return a + b * x <= d * c * x;
}

void solve()
{
    cin >> a >> b >> c >> d;
    if(c * d <= b){
        cout << -1 << "\n";
        return;
    }

    ll l = -1LL;
    ll r = 1e8;
    while(r - l > 1LL){
        ll mid = (r + l) / 2LL;
        if(ok(mid)){
            r = mid;
        } else {
            l = mid;
        }
    }
    cout << r << "\n";
}

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long const mod = 1e9+7;
int main(){
    long n,m;
    cin >> n >> m;
    vector<long>h(n);
    vector<long>w(m);
    for(int i=0;i<n;i++)cin >> h[i];
    for(int i=0;i<m;i++)cin >> w[i];
    sort(h.begin(),h.end());
    sort(w.begin(),w.end());

    vector<long>guki(n);
    guki[0] = -h[0];
    int a = -1;
    for(int i=1;i<n;i++){
        a *= -1;
        guki[i] = guki[i-1] + a*h[i];
    }

    long ans = 1LL << 60;
    for(int i=0;i<m;i++){
        long tmp = 0;
        int cnt = upper_bound(h.begin(),h.end(), w[i]) - h.begin();
        if(cnt % 2 == 0){
            if(cnt != 0)tmp += guki[cnt-1];
            tmp -= w[i];

        }else{
            tmp += guki[cnt - 1];
            tmp += w[i];
        }

        if(cnt == 0){
                tmp -= guki[n-1];
        }else{
                tmp -= (guki[n-1] - guki[cnt-1]);
        }
        ans = min(ans, tmp);

    }
    cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
long long n, m, Num, a[maxn], b[maxn], cnt[maxn * 2], lstt[maxn * 2], ans = 1e18;
struct My {
	long long val, pos, kkk;
	inline My() {}
	inline My(long long val, long long pos, long long kkk) : val(val), pos(pos), kkk(kkk) {}
} q[maxn * 2];
inline bool comp(const My &x, const My &y) {
	return x.val < y.val;
}
int main() {
	scanf("%lld%lld", &n, &m);
	for (long long i = 1; i <= n; ++i) {
		scanf("%lld", &a[i]);
		q[i] = My(a[i], i, 1);
	}
	for (long long i = 1; i <= m; ++i) {
		scanf("%lld", &b[i]);
		q[i + n] = My(b[i], i, 2);
	}

	sort(q + 1, q + n + m + 1, comp);

	for (long long i = 1, lnk = -1; i <= n + m; ++i) {
		if (q[i].kkk == 1) {
			if (lnk != -1) {
				cnt[i] = cnt[i - 1] + abs(q[i].val - lnk);
				lnk = -1;
			}
			else {
				lnk = q[i].val; cnt[i] = cnt[i - 1];
			}
		} else cnt[i] = cnt[i - 1];
	}

	for (long long i = n + m, lnk = -1; i; --i) {
		if (q[i].kkk == 1) {
			if (lnk != -1) {
				lstt[i] = lstt[i + 1] + abs(q[i].val - lnk);
				lnk = -1;
			}
			else lnk = q[i].val, lstt[i] = lstt[i + 1];
		} else lstt[i] = lstt[i + 1];
	}

	for (long long i = 1, lnk = -1; i <= n + m; ++i) {
		if (q[i].kkk == 2) {
			if (lnk != -1) {
				ans = min(cnt[i] + lstt[i] + abs(q[i].val - lnk), ans);
				++Num;
			}
		} else {

			if (lnk != -1) lnk = -1;
			else lnk = q[i].val;
		}
	}

	for (long long i = n + m, lnk = -1; i; --i) {
		if (q[i].kkk == 2) {
			if (lnk != -1) {
				ans = min(cnt[i] + lstt[i] + abs(q[i].val - lnk), ans);
				++Num;
			}
		} else {
			if (lnk != -1) lnk = -1; else lnk = q[i].val;
		}
	}

	printf("%lld\n", ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back

LL n;
LL F[91];
vector<int> seq;
vector<int> ans;

int main()
{
	cin>>n;
	F[1]=F[2]=1;
	for(int i=3;i<=90;i++)
		F[i]=F[i-1]+F[i-2];
	for(int i=90;i>=1;i--)
		if(n>=F[i]) n-=F[i],seq.pb(1);
		else if(seq.size()) seq.pb(0);
	reverse(seq.begin(),seq.end());
	seq.pop_back();
	reverse(seq.begin(),seq.end());
	int P=seq.size()&1;
	ans.pb(1+P);
	for(int i=0;i<seq.size();i++)
	{
		P=1-P;
		ans.pb(3+P);
		if(seq[i]) ans.pb(1+P);
	}
	cout<<ans.size()<<'\n';
	for(int i=0;i<ans.size();i++)
		cout<<ans[i]<<'\n';

	return 0;
}

//GIVE ME AC!!!!!!!!!!!!!!!!!
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define ll int
#define ld long double
#define floatset() fixed<<setprecision(15)
#define all(n) n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
#define rep(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define pb push_back
#define eb emplace_back
#define INT(...) int __VA_ARGS__;scan(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;scan(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;scan(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;scan(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;scan(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;scan(__VA_ARGS__)
using namespace std;
using vl=vector<ll>;
using vi=vector<int>;
using vs=vector<string>;
using vc=vector<char>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using vvc=vector<vc>;
using vd=vector<double>;
using vp=vector<P>;
using vb=vector<bool>;
using P=pair<ll,ll>;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const ll MOD=1000000007;
const ll mod=998244353;
const double pi=acos(-1);
template<typename T1,typename T2 >
ostream &operator<<(ostream&os,const pair<T1,T2>&p) {
  os<<p.first<<" "<<p.second;
  return os;
}
template<typename T1,typename T2>
istream &operator>>(istream&is,pair<T1,T2>&p) {
  is>>p.first>>p.second;
  return is;
}
template<typename T>
ostream &operator<<(ostream&os,const vector<T>&v) {
  for(int i=0;i<(int)v.size();i++) {
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  return os;
}
template<typename T>
istream &operator>>(istream&is,vector<T>&v) {
  for(T &in:v)is>>in;
  return is;
}
void scan(){}
template<class Head,class... Tail>
void scan(Head&head,Tail&... tail) {
    cin>>head;
    scan(tail...);
}
template<class T>
void print(const T &t) { cout << t << '\n'; }
template<class Head, class... Tail>
void print(const Head &head, const Tail &... tail) {
    cout << head << ' ';
    print(tail...);
}
template<class... T>
void fin(const T &... a) {
    print(a...);
    exit(0);
}
template<typename T1,typename T2>
inline bool chmax(T1&a,T2 b){return a<b&&(a=b,true);}
template<typename T1,typename T2>
inline bool chmin(T1&a,T2 b){return a>b&&(a=b,true);}
vector<ll>prime_factorize(ll N) {
  vector<ll>res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        while (N % a == 0) {
            N /= a;
        }
        res.push_back(a);
      if(N==1)break;
    }
    if (N != 1) res.push_back(N);
    return res;
}
int main(){
  LL(l,r);
  long long ans=0;
  rep(i,max(2,l),r+1){
    vl p=prime_factorize(i);
    ll cnt=0;
    ll s=p.size();
    rep(bit,1,(1<<s)){
      ll now=1;
      rep(j,0,p.size()){
        if((bit>>j)&1){
          now*=p[j];
        }
      }
      ll res=(r/now)-((i-1)/now);
      if(__builtin_popcount(bit)%2==1){
        cnt+=res;
      }
      else{
        cnt-=res;
      }
    }
    ans+=cnt;
  }
  rep(i,max(2,l),r+1){
    ans-=r/i;
  }
  fin(ans*2);
}


#include <bits/stdc++.h>
using namespace std;

int main(){
  long long N;
  cin >> N;
  vector<long long> A(N),B(N);
  for(int i=0;i<N;i++) cin >> A[i];
  for(int i=0;i<N;i++) cin >> B[i];

  long long Amax=0;
  priority_queue<long long> Q;
  for(int i=0;i<N;i++){
    Amax = max(Amax,A[i]);
    Q.push(Amax * B[i]);
    cout << Q.top() << endl;
  }
  return 0;
}

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
////
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>

#include <utility>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back

using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
//#ifdef __int128
//using hll = __int128;
//#endif
using pii = pair<ll, ll>;
using ld = long double;

template <typename T>
void do_uniq(vector<T> &vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

#ifndef ONLINE_JUDGE

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}
#endif

#ifdef _getchar_nolock
#else
#    define _getchar_nolock getchar_unlocked
#endif

#define integer int

integer mod = 1e9 + 7;

integer ml(integer a, integer b) {
    return (a * 1ll * b) % mod;
}

integer add(integer a, integer b) {
    integer rt = a + b;
    if (rt < mod) return rt;
    return rt - mod;
}

integer sub(integer a, integer b) {
    return add(a, mod - b);
}

integer sq(integer a) {
    return ml(a, a);
}

integer b_p(integer b, ll p) {
    if (p == 0) return 1;
    if (p & 1) return ml(b, b_p(b, p - 1));
    return sq(b_p(b, p >> 1));
}

const ll inf = 1e18 + 231;

#define solvsh
//#define multi

#ifdef solvsh

void precalc() {}
const int INF = 2e9;

vector<int> divs[200];

const int MAXN = 52;

ld C[MAXN][MAXN];

void solve() {

    int n;
    cin >> n;
    vector<ll> ai;
    vector<ll> bi;

    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ai.push_back(a);
    }
    for (int i = 0; i < n; ++i) {
        int b;
        cin >> b;
        bi.push_back(b);
    }

    ll a_mx = ai[0];
    ll c_mx = bi[0] * ai[0];

    for (int i = 0; i < n; ++i) {
        a_mx = max(a_mx, ai[i]);
        c_mx = max(c_mx, bi[i] * a_mx);

        cout << c_mx<< "\n";
    }

}

#else

void precalc() {}

void solve() {}

#endif

void multisolve() {
    precalc();
    int t;

    cin >> t;

    int i = 1;
    while (t--) {
        solve();
        i++;
    }
}

void singlesolve (){
    precalc();
    solve();
}

#ifndef ONLINE_JUDGE

void gen() {
}

#endif

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifdef multi
    //            gen();
    multisolve();
#else
    singlesolve();
//    gen();
#endif
//     time_calc();
}


#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr LL mod = 998244353;
constexpr int maxn = 200000 + 1;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K;
    cin >> N >> K;
    vector<vector<int>> G(N + 1);
    for(int i = 1, u, v; i < N; i += 1){
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    vector<int> size(N + 1), cut(N + 1), msize(N + 1);
    int center = 0;
    function<void(int, int, int)> fc = [&](int u, int par, int tot){
        size[u] = 1;
        msize[u] = 0;
        for(int v : G[u]) if(v != par and not cut[v]){
            fc(v, u, tot);
            size[u] += size[v];
            msize[u] = max(msize[u], size[v]);
        }
        msize[u] = max(msize[u], tot - size[u]);
        if(msize[u] < msize[center]) center = u;
    };
    msize[center] = INT_MAX;
    fc(1, 0, N);
    vector<vector<pair<int, int>>> vvn(N + 1);
    function<void(int, int, int, int)> DFS = [&](int u, int par, int dep, int root){
        vvn[u].push_back({root, dep});
        for(int v : G[u]) if(v != par and not cut[v]) DFS(v, u, dep + 1, root);
    };
    function <void(int, int)> solve = [&](int u, int tot){
        vvn[u].push_back({u, 0});
        for(int v : G[u]) if(not cut[v])
            DFS(v, u, 1, u);
        cut[u] = 1;
        for(int v : G[u]) if(not cut[v]){
            center = 0;
            if(size[v] > size[u]) size[v] = tot - size[u];
            fc(v, 0, size[v]);
            solve(center, size[v]);
        }
    };
    solve(center, N);
    vector<vector<int>> par(N + 1, vector<int>(19));
    vector<int> dep(N + 1), p(N + 1);
    function<void(int)> dfs = [&](int u){
        for(int i = 1; i < 20; i += 1)
            par[u][i] = par[par[u][i - 1]][i - 1];
        for(int v : G[u]) if(par[u][0] != v){
            par[v][0] = u;
            dep[v] = dep[u] + 1;
            dfs(v);
        }
    };
    auto ga = [&](int u, int k){
        for(int i = 19; i >= 0; i -= 1)
            if(k >= (1 << i)){
                k -= 1 << i;
                u = par[u][i];
            }
        return u;
    };
    dfs(1);
    for(int i = 1; i <= N; i += 1) p[i] = i;
    sort(p.begin() + 1, p.end(), [&](const int& x, const int& y){
        return dep[x] > dep[y];
    });
    int L = 1, R = N - 1;
    while(L < R){
        int M = (L + R) >> 1, k = 0;
        //cout << L << " " << R << " " << M << endl;
        vector<int> d(N + 1, -1E9);
        for(int i = 1; i <= N; i += 1){
            int u = p[i], vis = 0;
            for(auto [v, dr] : vvn[u])
                if(d[v] >= dr) vis = 1;
            if(vis) continue;
            k += 1;
            int x = ga(u, M);
            if(x == 0) break;
            for(auto [v, dr] : vvn[x]) if(M >= dr)
                d[v] = max(d[v], M - dr);
        }
        //cout << k << endl;
        if(k > K) L = M + 1;
        else R = M;
    }
    cout << L << "\n";
    return 0;
}

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

using namespace std;

using i64 = long long;
#define forn(a, e) for (i64 a = 0; a < (i64)(e); a++)
#define forr(a, s, e) for (i64 a = s; a < (i64)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using iip = pair<int, int>;
using llp = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }
template<typename T, size_t N>
istream& operator>>(istream& is, array<T, N>& c) { for (auto& e : c) is >> e; return is; }

template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

// const i64 INF = 2e18;
const int INF = 2e9;
const __int128_t M = 1000000;
const int MXB = 20;
using bin = bitset<MXB + 1>;
const double EPS = 1e-8;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    rande.seed(chrono::steady_clock::now().time_since_epoch().count());

    string s;
    while (read(s)) {
        int n = s.size();
        auto cc = make_vec(0, n + 1, 26);

        for (int i = n - 1; i >= 0; i--) {
            for (int j = 0; j < 26; j++) {
                cc[i][j] = cc[i + 1][j];
            }

            cc[i][s[i] - 'a']++;
        }

        i64 ans = 0;
        int lp = n;
        char lc = 0;
        for (int i = n - 3; i >= 0; i--) {
            if (s[i] == s[i + 1] && s[i + 1] != s[i + 2]) {

                int cl = cc[i + 2][s[i] - 'a'] - cc[lp][s[i] - 'a'];
                ans += max(0, lp - (i + 2) - cl);

                if (s[i] != lc) {
                    ans += n - lp;
                }

                lp = i;
                lc = s[i];
            }
        }

        cout << ans << endl;
    }
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef std::vector<bool> vb;
typedef std::vector<std::vector<bool>> vvb;
typedef std::vector<string> vstr;
typedef std::pair<long long, long long> pll;
#define INF 1999999999
#define INFLL std::numeric_limits<long long>::max()
#define MODA 1000000007
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define rep1(i,n) for (long long i = 1; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define errv1(x) cerr << #x <<" "<< x << endl;
#define errv2(x, y) cerr << #x <<" "<< x <<" "<< #y <<" "<< y << endl;
#define errv3(x, y, z) cerr << #x <<":"<< x <<" "<< #y <<":"<< y <<" "<< #z <<":"<< z << endl;
#define errv4(x, y, z, a) cerr << #x <<":"<< x <<" "<< #y <<":"<< y <<" "<< #z <<":"<< z <<" "<< #a <<":"<< a << endl;

int main() {
  ll H, W;
  cin >> H >> W;
  vvll A(H, vll(W));
  rep(i,H){
    rep(j,W){
      cin >> A[i][j];
    }
  }

  ll mini = INFLL;
  rep(i,H){
    rep(j,W){
      mini = min(mini, A[i][j]);
    }
  }

  ll ans =0;
  rep(i,H){
    rep(j,W){
      ans += A[i][j] - mini;
    }
  }
  cout << ans << endl;
  return 0;
}

#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <list>
#include <cassert>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define ll long long
#define repi(i,a,b) for(ll i=a;i<b;++i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
using vvv = vector<vector<vector<ll>>>;
using vv = vector<vector<ll>>;
using vec = vector<ll>;
using P = pair<ll, ll>;

int main(void) {
	ll n; cin >> n;
	ll ans = INF;
	rep(i, n) {
		ll a, p, x; cin >> a >> p >> x;
		if (x - a > 0) ans = min(ans, p);
	}
	if (ans == INF) ans = -1;
	cout << ans << endl;
	system("pause");
}


#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main ()
{

	string s[3];
	int per[10];

	set<char> sc;
	rep(i,3){
		cin>>s[i];
		rep(j,s[i].length()){
			sc.insert(s[i][j]);
		}
	}
	if (sc.size()>10) {
		cout<< "UNSOLVABLE";
		return 0;
	}
	iota (per,per+10,0);
	map<char,int> ci;

	int il =0;
	do{
		long num[3]={0};
		bool check = true;
		int ii =0;
		for ( auto it = sc.begin(); it != sc.end();it++ ){
			ci[*it] = per[ii];
			ii++;
		}

		rep(i,3){
			rep(j,s[i].length()) {
				int temp = ci[s[i][j]];
				num[i]*=10; num[i]+=temp;
				if (j==0 && temp ==0) check =false;
			}
		}
		if (check== true){
			if (num[0]+num[1]==num[2]){
				cout<<num[0]<<endl<<num[1]<<endl<<num[2];
				return 0;
			}
		}

	}while (next_permutation(per,per+10));
	cout<< "UNSOLVABLE";
	return 0;

}

#pragma GCC optimize("O3")

#include <bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// using cint = cpp_int;

#define fastio \
std::cin.tie(nullptr); \
std::ios::sync_with_stdio(false);

using ll = long long;
using ld = long double;

#define For(i, m, n)    for(int i = (m); (i) < (n); ++(i))
#define Rep(i, n)       For(i, 0, n)
#define Each(e, con)    for(auto e: con)
#define rEach(e, con)   for(auto &e: con)
#define crEach(e, con)  for(const auto &e: con)

#define All(con)        (con).begin(), (con).end()
#define Unique(con)     std::sort(All(con)); (con).erase(std::unique(All(con)), (con).end())
#define Reverse(con)    std::reverse(All(con))
#define Middle(con)     (con).begin() + ((con).end() - (con).begin()) / 2

template <class Ty1, class Ty2>
std::istream &operator>>(std::istream &is, std::pair<Ty1, Ty2> &arg)
{ is >> arg.first >> arg.second; return is; }
template <class Ty>
std::istream &operator>>(std::istream &is, std::vector<Ty> &arg)
{ rEach(e, arg) is >> e; return is; }
template <class Ty>
std::istream &operator>>(std::istream &is, std::vector<std::vector<Ty>> &arg)
{ rEach(sub, arg) { rEach(e, sub) { is >> e; }} return is; }

template <class Ty1, class Ty2>
std::istream &vecinput(std::vector<Ty1> &arg1, std::vector<Ty2> &arg2)
{ assert(arg1.size() == arg2.size());
auto sz = arg1.size(); Rep(i, (int)sz) std::cin >> arg1[i] >> arg2[i]; return std::cin; }
template <class Ty1, class Ty2, class Ty3>
std::istream &vecinput(std::vector<Ty1> &arg1, std::vector<Ty2> &arg2, std::vector<Ty3> &arg3)
{ assert(arg1.size() == arg2.size()); assert(arg2.size() == arg3.size());
auto sz = arg1.size(); Rep(i, (int)sz) std::cin >> arg1[i] >> arg2[i] >> arg3[i]; return std::cin; }
template <class Ty1, class Ty2, class Ty3, class Ty4>
std::istream &vecinput(std::vector<Ty1> &arg1, std::vector<Ty2> &arg2, std::vector<Ty3> &arg3, std::vector<Ty4> &arg4)
{ assert(arg1.size() == arg2.size()); assert(arg2.size() == arg3.size()); assert(arg3.size() == arg4.size());
auto sz = arg1.size(); Rep(i, (int)sz) std::cin >> arg1[i] >> arg2[i] >> arg3[i] >> arg4[i]; return std::cin; }

int main() {
fastio

    string a, b, c;
    cin >> a >> b >> c;

    vector<char> alpha;
    crEach(e, a) alpha.push_back(e);
    crEach(e, b) alpha.push_back(e);
    crEach(e, c) alpha.push_back(e);

    Unique(alpha);
    if(alpha.size() > 10) {
        puts("UNSOLVABLE");
        return 0;
    }

    vector<int> digit{0,1,2,3,4,5,6,7,8,9};
    map<char, int> mp;
    do {
        Rep(i, (int)alpha.size()) {
            mp[alpha[i]] = digit[i];
        }

        ll x = 0, y = 0, z = 0;

        if(mp[a[0]] == 0) continue;
        if(mp[b[0]] == 0) continue;
        if(mp[c[0]] == 0) continue;

        Rep(i, (int)a.size()) x = x * 10 + mp[a[i]];
        Rep(i, (int)b.size()) y = y * 10 + mp[b[i]];
        Rep(i, (int)c.size()) z = z * 10 + mp[c[i]];

        if(x + y == z) {
            cout << x << endl;
            cout << y << endl;
            cout << z << endl;
            return 0;
        }
    } while(next_permutation(All(digit)));

    puts("UNSOLVABLE");

    return 0;
}


//  main.cpp
//  ABC182F
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int,int>;

int main(int argc, const char * argv[]) {
    int n;
    cin>>n; // コインの種類数、コインが１円だけの時、払い方は１通り
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    ll x;
    cin>>x; // 代金
    vector<ll>a(n); // コイン
    rep(i,n) cin>>a[i];
    if(x%a[n-1]==0){
        cout<<1<<endl;
        return 0;
    }
    vector<ll>r(n); // 使える枚数
    rep(i,n-1) r[i]=a[i+1]/a[i]-1;
    r[n-1]=x/a[n-1];
    vector<ll> d(2); // 代金との差額
    d[0]=a[n-1]*r[n-1]-x;
    d[1]=a[n-1]*(r[n-1]+1)-x;
    ll e=0;
    // i番目までで、代金との差d=map->firstになる個数
    // 代金との差はたかだか２種類、数値が大きいのでmapで管理する
    vector<vector<int>>dp(n,vector<int>(2));
    dp[n-1][0]=1;
    dp[n-1][1]=1;
    map<ll,ll>mp0,mp1;
    int i=n-2;
    while(d[0]!=0){
        mp0.clear();
        if(abs(d[0])<a[i]) mp0[d[0]]++;
        ll lmt0=d[0]/a[i]; // 調査する範囲を絞る　TLE解消
        for(ll j=lmt0-1;j<=lmt0+1;j++){
            if(j==0)continue;
            if(abs(j)>r[i])continue;
            e=d[0]+a[i]*j;
            if(abs(e)<a[i]){
                mp0[e]++;
                if(mp0.size()==2) break;
            }
            e=d[0]-a[i]*j;
            if(abs(e)<a[i]){
                mp0[e]++;
                if(mp0.size()==2) break;
            }
        }
        map<ll,int>nd;// 次のdの候補
        for(auto es=mp0.begin();es!=mp0.end();es++){
            nd[es->first]++;
            if(mp0.begin()->first==es->first){
                dp[i][0]+=es->second*dp[i+1][0];
            }else{
                dp[i][1]+=es->second*dp[i+1][0];
            }
        }
        mp1.clear();
        if(abs(d[1])<a[i]) mp1[d[1]]++;
        ll lmt1=d[1]/a[i]; // 調査する範囲を絞る　TLE解消
        for(ll j=lmt1-1;j<=lmt1+1;j++){
            if(j==0) continue;
            if(abs(j)>r[i])continue;
            e=d[1]+a[i]*j;
            if(abs(e)<a[i]){
                mp1[e]++;
                if(mp1.size()==2) break;
            }
            e=d[1]-a[i]*j;
            if(abs(e)<a[i]){
                mp1[e]++;
                if(mp1.size()==2) break;
            }
        }
        for(auto es=mp1.begin();es!=mp1.end();es++){
            nd[es->first]++;
            if(mp0.begin()->first==es->first){
                dp[i][0]+=es->second*dp[i+1][1];
            }else{
                dp[i][1]+=es->second*dp[i+1][1];
            }
        }
        int d_cnt=0;
        for(auto cs=nd.begin();cs!=nd.end();cs++){
            d[d_cnt]=cs->first;
            d_cnt++;
        }
        i--;
        if(i<0) i=0;
    }
    ll ans=dp[i+1][0]+dp[i+1][1];

    cout<<ans<<endl;
    return 0;
}
/*
 2 300
 1 100
 */

#include<bits/stdc++.h>
using namespace std;
#define eps 1e-10
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<r;i++)
#define rrep(i,r,l) for(int i=r-1;i>=l;i--)
typedef long long ll;
int n;
ll x,a[55],b[55];
map<ll,int> v;
int main()
{
	scanf("%d%lld",&n,&x);
	rep(i,0,n) scanf("%lld",&a[i]);
 	rep(i,0,n-1) b[i]=a[i+1]/a[i];
	v[x%a[n-1]]=1;
	if(x%a[n-1]!=0) v[x%a[n-1]-a[n-1]]=1;
	rrep(i,n-1,0){
		map<ll,int> u;
		for(auto x:v){
			ll c=(x.first+a[i+1])%a[i];
			ll d=(x.first-c)/a[i];
			if(abs(d)<b[i]) u[c]+=x.second;
			if(c&&abs(d+1)<b[i]) u[c-a[i]]+=x.second;
		}
		v.clear(),v=u;
	}
	printf("%lld\n",v[0]);
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define max_value 0x3f3f3f
#define all(v) v.begin(),v.end()
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
using namespace std;
typedef pair<ll,ll> pii;

const int  inf=1e9+7;
const int mod=998244353;
const int maxn=2e3+1;
ll sqr(ll x){
return x*x;
}
/*ll invfac(ll a,ll b){
 return (f[a]*modexpo((f[b]*f[a-b])%inf,inf-2))%inf;

}*/
ll modexpo(ll a,ll b){
    a%=inf;
ll res=1;
 while(b>0){
    if(b&1)
        res=res*a%inf;
    a=a*a%inf;
    b>>=1;
 }
 return res;

}

void solve(){
ll sum=0;
ll n,k;
cin>>n>>k;
ll z=100;
for(int j=1;j<=n;j++){
for(ll i=1;i<=k;i++){
    sum+=z+i;
}
z+=100;}
cout<<sum;

}

int main(){

  /*file;*/

 int t;
t=1;
 while(t--){
 solve();
}

}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,x,n) for(int i=x;i<=n;i++)
#define all(v) v.begin(),v.end()
#define foreach(c,itr) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)
#define p_b push_back
#define pii pair<int,int>
#define fr first
#define sc second
#define m_p make_pair
#define zero(a) memset(a,0,sizeof(a))
#define setp setprecision
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f;
const ll mod=1000000007;
const ld eps=1e-14;
int i,j;

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

	int n,k;
	cin>>n>>k;
	int ans=n*(n+1)/2*100*k+k*(k+1)/2*n;
	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define f first
#define s second
#define pb push_back
#define endl '\n'
const int N=3e5+5;

int cnt[N];

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, k;
	cin>>n>>k;
	for(int i=0; i<n; i++){
		int x;
		cin>>x;
		cnt[x]++;
		cnt[x]=min(cnt[x], k);
	}

	int ans=0;
	int rem=k;
	for(int i=0; i<N; i++){
		int cn=min(cnt[i], rem);
		if(cn==rem){
			continue;
		}
		else{
			ans+=i*(rem-cn);
			rem=cn;
		}
	}
	cout<<ans;

	return 0;
}

#include <bits/stdc++.h>

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 raw_x) : x(raw_x) {
    if (x >= P || x < 0) {
    x %= P;
    if (x < 0) x += P;
  }
}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};
ostream& operator<<(ostream& s, const FiniteField& x) { s << x.Value(); return s; }

FiniteField Solve() {
  int n;
  cin >> n;
  int64 m;
  cin >> m;

  int64 s = 0;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    s += xs[i];
  }

  if (m < s) {
    return 0;
  }
  int64 r = m - s;
  int64 g = s + n - 1;
  int64 a = r + g + 1;
  int64 b = g + 1;
  FiniteField x = 1;
  for (int64 i = 1; i <= b; i++) {
    x *= (a - i + 1);
    x /= i;
  }
  return x;
}

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

  cout << Solve() << endl;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <cstring>
#include <list>
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))
std::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

const int MAXN = 200000;

int n, m;
int s[MAXN], t[MAXN];
vector<int> adj[MAXN];

bool done[MAXN];
int q[MAXN], qhead, qtail;

bool solve() {
	REP(i, n) done[i] = false;
	REP(i, n) if (!done[i]) {
		qhead = qtail = 0; q[qhead++] = i, done[i] = true; ll ssum = 0, tsum = 0;
		while (qtail < qhead) {
			int at = q[qtail++];
			ssum += s[at], tsum += t[at];
			REPSZ(j, adj[at]) {
				int to = adj[at][j];
				if (!done[to]) done[to] = true, q[qhead++] = to;
			}
		}
		if (ssum != tsum) return false;
	}
	return true;
}

void run() {
	scanf("%d%d", &n, &m);
	REP(i, n) scanf("%d", &s[i]);
	REP(i, n) scanf("%d", &t[i]);
	REP(i, m) { int a, b; scanf("%d%d", &a, &b); --a, --b; adj[a].PB(b); adj[b].PB(a); }
	printf("%s\n", solve() ? "Yes" : "No");
}

int main() {
	run();
	return 0;
}

//Author: master19
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define mod 1000000007LL // fixed...
#define modd 1000000007LL // Can be changed for global use
#define all(arr) arr.begin(),arr.end()
#define x(arr) arr.begin(),arr.end()
#define ulli unsigned long long int
#define assign(x,val) memset(x,val,sizeof(x))
#define prec(val, dig) fixed << setprecision(dig) << val
#define Sort(arr) sort(arr.begin(), arr.end())
#define time() std::chrono::high_resolution_clock::now();
#define lower(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define upper(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
#define crap ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define get(arr, num) vector < ll > arr(num); for(int i=0; i<num; i++)cin >> arr[i];
#define get_set(arr, num, st, type) set < type > st; for(int i=0; i<num; i++) st.insert(arr[i]);
#define put(arr, num) for(int i=0; i<num; i++)cout << arr[i] << " "; cout << endl;
#define Time(start, finish) std::chrono::duration<double> elapsed = finish - start; cout << elapsed.count() << endl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > new_ds;
void debug_out() { cerr << endl; }
template <typename HeadStart, typename... TailEnd>
void debug_out(HeadStart H, TailEnd... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
ll lets_do_it();
ll dx[] = {-1, 1, 0, 0};
ll dy[] = {0, 0, -1, 1};
pair < ll, ll > dig[] = {{-1, -1}, {-1, 1}, {1, 1}, {1, -1}};
bool isValid(ll x, ll y, ll row, ll col){
    return ((x>=0) && (y >=0)  && (x < row) && (y < col));
}
int main(int argc, const char** argv) {
    crap;
    ll test = 1;
    // cin >> test;
    auto start = std::chrono::high_resolution_clock::now();
    for(int loop=0; loop<test; loop++){
        // cout << "Case #" << (loop+1) << ": ";
        lets_do_it();
    }
    auto finish = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> elapsed = finish - start;
    cerr << "Game is on :-> " << elapsed.count() << "s"<< endl;
    return 0;
}
ll dfs(vector < vector < ll > > & graph, vector < ll > & init, vector < ll >& final, vector < bool > & visit, ll start, ll *left, ll *right){
    *left += init[start-1];
    *right += final[start-1];
    visit[start] = true;
    for(int i=0; i<graph[start].size(); i++){
        if(!visit[graph[start][i]]){
            dfs(graph, init, final, visit, graph[start][i], left, right);
        }
    }
    return 0;
}
bool dfsHelper(vector < vector < ll > > &graph, vector < ll >&init, vector < ll >&final){
    vector < bool > visit(graph.size(), false);
    ll left = 0, right = 0;
    bool res = true;
    for(int i=1; i<graph.size(); i++){
        if(!visit[i]){
            left = 0, right = 0;
            dfs(graph, init, final, visit, i, &left, &right);
            if(left == right)
                res = res & true;
            else
                res = res & false;
            // debug(res, i, left, right);
        }
    }
    return res;
}
ll lets_do_it(){
    // Your code goes by here !!
    ll num, val;
    cin >> num >> val;
    get(init, num);
    get(final, num);
    vector < vector < ll > > graph(num+1);
    ll u, v;
    for(int i=0; i<val; i++){
        cin >> u >> v;
        graph[u].pb(v);
        graph[v].pb(u);
    }
    if(dfsHelper(graph, init, final))
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


#include <bits/stdc++.h>
#include<iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int64_t N, a, b;
    vector<int64_t> square_number;
    cin >> N;
    for(a = 2; N >= pow(a, 2); a++){
        for(b = 2; N >= pow(a, b); b++){
            square_number.push_back(pow(a, b));
        }
    }
    sort(square_number.begin(), square_number.end());
    square_number.erase(unique(square_number.begin(), square_number.end()), square_number.end());
    int size = square_number.size();
    cout << N - size << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i =0;i<(int)(n);i++)
#define endl '\n'
typedef pair<int,int> P;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    set<string> s1;
    set<string> s2;
    int n;
    cin >> n;
    string ans = "satisfiable";
    rep(i,n){
        string s;
        cin >> s;
        if(s[0]=='!'){
            string t = s.substr(1,s.size()-1);
            if(s2.find(t)!=s2.end()){
                ans = t;
            }
            s1.insert(s);
        }
        else{
            string t = "!"+s;
            if (s1.find(t) != s1.end())
            {
                ans = s;
            }
            s2.insert(s);
        }
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=200005;
#define M 1000000007
#define double long double
#define BINF 100000000000000
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 17500001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;

int n, k;
int a[N], power[105];
string s;
int dp[101][101][101];

int get(int x, int y){
    if(x == y) return x;
    int s = x + y;
    if(s == 1) return 1;
    if(s == 2) return 0;
    return 2;
}

int get(int l, int r, int lvl){
   // cout << l << ' ' << r << ' ' << lvl << endl;
    if(lvl == 1){
        return get(a[l], a[r]);
    }
    if(dp[l][r][lvl] != -1) return dp[l][r][lvl];

    int g = power[lvl - 1];

    int x = get(l, (l + g - 1 + n) % n, lvl - 1);
    int y = get((l + g) % n , r, lvl - 1);

    return dp[l][r][lvl] = get(x, y);
}

#undef int
int main() {
#define int long long int
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("optput.txt", "w", stdout);
#endif

    cin >> n >> k;
    cin >> s;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R') a[i] = 0;
        else if(s[i] == 'P') a[i] = 1;
        else a[i] = 2;
    }

    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            for(int l = 0; l <= k; l++){
                dp[i][j][l] = -1;
            }
        }
    }

    power[0] = 1;
    for(int i = 1; i < 105; i++){
        power[i] = (2 * power[i - 1]) % n;
    }

    int ans = get(0, (power[k] - 1 + n) % n, k);

    if(ans == 0) cout << "R\n";
    else if(ans == 1) cout << "P\n";
    else cout << "S\n";

return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
    long long n,m,k;
    cin>>n>>m>>k;
    vector<long long> data(2000010,0),datac(2000010,0);
    if(n>m+k){
        cout<<0<<endl;
        return 0;
    }
    set<ll> sosuu;
    for(ll i=2;i<2000010;i++){
        sosuu.insert(i);
    }
    for(ll i=2;i<1500;i++){
        if(!sosuu.count(i)){
            continue;
        }
        for(ll j=2;j*i<2000010;j++){
            if(sosuu.count(i*j)){
                sosuu.erase(i*j);
            }
        }
    }

    for(ll x:sosuu){
        ll y=x;
        while(y<=n+m){
            data.at(x)+=(n+m)/y;
            data.at(x)-=n/y;
            data.at(x)-=m/y;
            y*=x;
        }
    }
    for(ll x:sosuu){
        ll y=x;
        while(y<=n+m){
            datac.at(x)+=(n+m)/y;
            datac.at(x)-=(n-k-1)/y;
            datac.at(x)-=(m+k+1)/y;
            y*=x;
        }
    }
    long long count=1,ccon=1;
    for(ll i=2;i<=n+m;i++){
        for(ll j=0;j<data.at(i);j++){
            count*=i;
            count%=1000000007;

        }
        //cout<<data.at(i)<<endl;
    }
    //cout<<endl;
    for(ll i=2;i<=n+m;i++){
        for(ll j=0;j<datac.at(i);j++){
            ccon*=i;
            ccon%=1000000007;
            //cout<<i<<endl;

        }
    }
    if(k==n){
        ccon=0;
    }
    //cout<<count<<" "<<ccon<<endl;
    cout<<(count-ccon+1000000007)%1000000007<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){

  int n;
  cin >> n;
  string s;
  cin >> s;

  vector<int> sumA(n+1,0);
  vector<int> sumG(n+1,0);
  vector<int> sumC(n+1,0);
  vector<int> sumT(n+1,0);

  rep1(i,n){
    sumA[i] = sumA[i-1] + (s[i-1] == 'A');
    sumG[i] = sumG[i-1] + (s[i-1] == 'G');
    sumC[i] = sumC[i-1] + (s[i-1] == 'C');
    sumT[i] = sumT[i-1] + (s[i-1] == 'T');
  }
  int ans = 0;
  rep(i,n){
    for(int j=i+1;j<n+1;j++){
      int nowA = sumA[j]-sumA[i];
      int nowG = sumG[j]-sumG[i];
      int nowC = sumC[j]-sumC[i];
      int nowT = sumT[j]-sumT[i];
      if(nowA == nowT && nowC == nowG) ans ++;
    }
  }
  cout << ans << endl;
}

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>
#include <utility>
#include <unordered_set>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define reps(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
const int MOD = 1000000007;

int main(){
    ll n;
    cin>>n;
    ll m;
    cin>>m;
    vector<string> s(n);
    for (ll i = 0; i < n; i++) {
		cin >> s[i];
	}
    vector<ll> cnt(n,0);
    rep(i,n){
        rep(j,m){
            if(s[i][j]=='1'){
                cnt[i]++;
            }
        }
    }

    ll odd=0,even=0;
    for( auto x : cnt){
        if(x%2==0){
            even++;
        }else{
            odd++;
        }
    }

    cout<<odd*even<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x,y,res;
map<ll,ll>mp;            //将a变成b需要的步数
ll dfs(ll k){
	if(k<=x) return x-k;             //-1 使x变小
	if(mp[k]) return mp[k];
	ll cnt=k-x;                     //k>x
	if(!(k&1)) cnt=min(cnt,dfs(k/2)+1);       //1步 *2的操作
	else cnt=min(cnt,min(dfs(k+1),dfs(k-1))+1);    //奇数则+1或-1
	mp[k]=cnt;                   //记忆化搜索
	return mp[k];
}
int main(void){
	while(cin>>x>>y){
		mp.clear();
		res=dfs(y);
		cout<<res<<endl;
	}
	return 0;
}

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include <tuple>
#include <numeric>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <regex>
#include <stack>
#include <limits>
#include <climits>

using namespace std;

map<long long, long long> f;

long long calc(long long y, long long x) {
	if (f.count(y) > 0) return f[y];
	if (y <= x) return x - y;
	long long res = y - x;
	if (y % 2 == 1) {
		res = min(res, 2+calc((y + 1) / 2, x));
		res = min(res, 2 + calc((y - 1) / 2, x));
	} else {
		res = min(res, 1 + calc(y / 2, x));
	}
	return f[y] = res;
}

int main() {
	ios_base::sync_with_stdio(false);
	long long x, y;
	cin >> x >> y;
	if (x >= y) {
		cout << x - y;
	} else {
		cout << calc(y, x);
	}
	cout << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,i=0,j=0;
    double b,s=0,y=100;
  cin>>a>>b;
   int c[a],d[a];
  for(i=0;i<a;i++){
    cin>>c[i];
    cin>>d[i];
  }
  for(i=0;i<a;i++)
    {
    s+=c[i]*d[i];
    if(s>b*y){
        j=1;
        cout<<i+1<<endl;
        break;
    }
    }
    if(j==0){
        cout<<-1<<endl;
    }
    return 0;
  }

#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=(a),(i##i)=(b);i<=(i##i);++i)
#define Rep(i,n) for(int i=0,(i##i)=(n);i<(i##i);++i)
#define Fodn(i,a,b) for(int i=(a),(i##i)=(b);i>=(i##i);--i)
#define pln puts("")
#define il inline
#define ff first
#define ss second
using LL=long long;using u32=unsigned int;using u64=unsigned LL;using LD=long double;
template<typename T>using pii=pair<T,T>;
template<typename T>il bool read(T&x){
x=0;char c=getchar();int f=1;while(!isdigit(c)&&(c!='-')&&(c!=EOF))c=getchar();
if(c==EOF)return 0;if(c=='-')f=-1,c=getchar();
while(isdigit(c)){x=(x<<1)+(x<<3)+(c&15);c=getchar();}x*=f;return 1;}
template<typename T,typename...Args>
il bool read(T&x,Args&...args){bool res=1;res&=read(x);res&=read(args...);return res;}
const int M=1000000007,INF=0x3f3f3f3f;const LL INFLL=0x3f3f3f3f3f3f3f3fLL;
const int N=1000010;const double EPS=1e-6;

int n,x;
bool f=0;
LL now;
inline void init(){
    read(n,x);x*=100;
    For(i,1,n){
        LL u,v;read(u,v);now+=u*v;
        if(now>x){
            f=1;printf("%d\n",i);break;
        }
    }
}
inline void solve(){
    if(!f)puts("-1");
}
signed main(){
    init();solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long int t,n,i,x,mx,mn,f,j,s,r,y;
    cin>>n;
    vector<long long int>v(402);
    for(i=0;i<n;i++)
    {
        cin>>x;
        v[x+200]++;
    }
    s=0;
    for(i=0;i<400;i++)
    {
        for(j=i;j<=400;j++)
        {
            if(i!=j&&v[i]>=0&&v[j]>=0)
            {
                r=(i-200)-(j-200);
                s+=(v[i]*v[j]*r*r);
            }
        }
    }
    cout<<s<<endl;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = 500 + 10;
int n, c[MAXN][MAXN];
int a[MAXN];
int b[MAXN];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            scanf("%d", &c[i][j]);
        }
    }

    a[1] = *min_element(c[1] + 1, c[1] + 1 + n);
    for (int j = 1; j <= n; ++j) {
        b[j] = c[1][j] - a[1];
    }
    for (int i = 2; i <= n; ++i) {
        a[i] = c[i][1] - b[1];
    }

    try {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                if (c[i][j] != (LL)a[i] + b[j]) {
                    throw false;
                }
            }
        }
    } catch (bool check) {
        puts("No");
        return 0;
    }

    puts("Yes");
    for (int i = 1; i <= n; ++i) {
        printf("%d ", a[i]);
    }
    puts("");
    for (int i = 1; i <= n; ++i) {
        printf("%d ", b[i]);
    }
    puts("");
    return 0;
}


#include <bits/stdc++.h> //yaad rkhne layak baatein
#include <bits/stdc++.h> // bool found = false use it to find some number after the given number with some cond.
                         // while (!found)
#include <iostream>      // freq.table-> int freq[26] = {0}; for (ll i = 0; i < s1.length(); i++) freq[s1[i] - 'A']++;
#define ll long long     //[s[i] - 'a'] ->this convers char to corr.int eg. 'c' to 3.
// if(a<=min1){
//         min2 = min1;
//         index2 = index1;
//         min1 = a;
//         index1 = i;         to find index of 2nd smallest element
//       }
//       else if(a<=min2){
//         min2 = a;
//         index2 = i;
//       }
#define INF 2000000000
#define pb push_back
using namespace std;
//cout<<fixed<<setprecision(12)<<ans<<endl;
const int M = 1e9 + 7;
#define loop0(i, n) for (ll i = 0; i < n; i++)            //  str.insert(0, 5, '1'); => it will insert 1 five times in start of str.
#define loop00(i, n) for (ll i = 0; i <= n; i++)
#define loop1(i, n) for (ll i = 1; i < n; i++)
#define loop11(i, n) for (ll i = 1; i <= n; i++)
#define loopab(i, a, b) for (ll i = a; i <= b; i++)

void flashSpeed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
}
long long mod(long long x)
{
    return ((x % M + M) % M);
}
long long add(long long a, long long b)
{
    return mod(mod(a) + mod(b));
}
long long mul(long long a, long long b)
{
    return mod(mod(a) * mod(b));
}
ll modPow(ll a, ll b)
{
    if (b == 0)
        return 1LL;
    if (b == 1)
        return a % M;
    ll res = 1;
    while (b)
    {
        if (b % 2 == 1)
            res = mul(res, a);
        a = mul(a, a);
        b = b / 2;
    }
    return res;
}
const int N = 2e5 + 2;
int fact[N];

void precalc()
{
    fact[0] = 1;
    for (int i = 1; i < N; i++)
    {
        fact[i] = mul(fact[i - 1], i);
    }
}

ll inv(ll x)
{
    return modPow(x, M - 2);
}

ll divide(ll a, ll b)
{
    return mul(a, inv(b));
}

ll nCr(ll n, ll r)
{
    return divide(fact[n], mul(fact[r], fact[n - r]));
}
double Round(double var)
{
    float value = (int)(var * 100 + .5);
    return (float)value / 100;
}
ll ceils(ll x, ll y) {
	return x / y + ((x % y) != 0);
}
ll Gcd(ll a, ll b)
{
    if (b > a)
    {
        return Gcd(b, a);
    }
    if (b == 0)
        return a;
    else
        return Gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / Gcd(a, b) * b;
}

bool isPal(string s)
{
    for (int i = 0; i < (int)s.size() / 2; i++)
    {
        if (s[i] != s[(int)s.size() - 1 - i])
            return false;
    }
    return true;
}

ll Sumdigits(ll a)
{
    ll total = 0;
    while (a)
    {
        total += a % 10;
        a /= 10;
    }
    return total;
}
bool isPerfectSquare(int n)
{
    for (int i = 1; i * i <= n; i++) {
        if ((n % i == 0) && (n / i == i)) {
            return true;
        }
    }
    return false;
}
bool isPowerOfTwo(int n){
   return (ceil(log2(n)) == floor(log2(n)));
}
void lexosmallest(string s,string c){
    string t1 = s;
    sort(t1.begin(), t1.end());
    int index = -1;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != t1[i]) {
            index = i;
            break;
        }
    }
    int j;
    for (int i = 0; i < s.length(); i++) {        //khela yha pe hua hai..loop poora chala hai
        if (s[i] == t1[index])
            j = i;
    }
    swap(s[index], s[j]);
}
void solution(){
   string s;
   string ans;
   cin>>s;
   for(auto c:s){
       if(c=='6'){
           ans.push_back('9');
       }else if(c=='9'){
           ans.push_back('6');
       }else{
           ans.push_back(c);
       }
   }
   reverse(ans.begin(),ans.end());
   cout<<ans<<endl;
}

int main()
{
    flashSpeed();
    int t=1;
   // cin>>t;
    while(t--)
    {
    solution();
}
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPE(i,l,n) for(ll i=l;i<=ll(n);i++)
#define FORA(i,I) for(const auto& i:I)
#define ALL(v) v.begin(),v.end()
#define UQ(v) v.erase(unique(ALL(v)), v.end())
#define ACM(v) accumulate(ALL(v), 0)
#define P(str) cout << str << endl
#define VLL vector<ll>
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
constexpr int64_t INF = 1e18;

ll my_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) return my_pow(x * x, n / 2);
    return x * my_pow(x, n - 1);
}

int main(){
    ll n;
    cin >> n;
    REPE(i, 1, INF){
        ll ttmp = n - my_pow(3, i);
        if(ttmp < 0) break;
        REPE(j, 1, INF){
        ll tmp = ttmp - my_pow(5, j);
        if(tmp < 0) break;
        else if(tmp == 0){
            cout << i << " " << j << endl;
            return 0;
        }
    }
    }
    P(-1);
}


#include<bits/stdc++.h>
#define ri register int
#define ll long long
using namespace std;
inline int rd(){
	int res = 0,f = 0;
	char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') f = 1;
	for(;isdigit(ch);ch = getchar()) res = (res<<3) + (res<<1) + ch - 48;
	return f ? -res : res;
}
int main(){
	int n = rd(),k = rd();
	ll ans = 0;
	for(ri i = 1;i <= n;++i)
		for(ri j = 1;j <= k;++j) ans += i*100 + j;
	printf("%lld\n",ans);
	return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < n; i++)

int main() {
    int n;  cin >> n;
    vector<ll> a(n), s(n+1, 0);
    set<ll> st;
    rep(i, n) {
        cin >> a[i];
        s[i+1] = a[i] + s[i];
    }
    ll ans = -1e18, tmp = 0;
    st.insert(s[0]);
    rep(i, n) {
        st.insert(s[i+1]);
        ans = max(tmp + *st.rbegin(), ans);
        tmp += s[i+1];
    }

    cout << ans << endl;
    return 0;
}

//小数点精度
//cout << fixed << std::setprecision(15) << y << endl;


#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/

constexpr lnt MOD = 998244353;
struct mint
{
	lnt v;
	mint():v(0){}
	mint(lnt v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(lnt k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(lnt n, lnt k) { if(n-k<k) k=n-k; mint num(1), dom(1); for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; } return num/dom; }
	static std::vector<mint> construct_comb(int n) {
		std::vector<mint> c(n+1); mint a = 1; c[0] = a; for(int i=1;i<=n;i++) { a = a*mint(n+1-i)/i; c[i] = a; } return c;
	}
	static std::vector<mint> construct_fact(int n) { std::vector<mint> f(n+1,1); for(int i=2;i<=n;i++) f[i]=f[i-1]*i; return f; }
};
std::istream& operator>>(std::istream&i,mint&a){ lnt t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }

int main() {
	int n,m;
	std::cin >> n >> m;
	mint ans=mint(n)*mint(m).pow(n);
	for(int x=2;x<=n;x++) {
		mint o=0;
		for(int y=1;y<=m;y++) {
			o+=mint(m-y).pow(x-2)*mint(m).pow(n-x);
		}
		ans-=o*mint(n-x+1);
	}
	print(ans);
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod=998244353;
ll n,m,ans,pw[5005][5005];
int main()
{
    cin>>n>>m;
    pw[0][0]=1;
    for(int i=1;i<=m;i++)
    {
        pw[i][0]=1;
        for(int j=1;j<=n;j++)
            pw[i][j]=(pw[i][j-1]*i)%mod;
    }
    ans=n;
    for(int i=1;i<=n;i++)
        ans=(ans*m)%mod;
    for(ll lg=2;lg<=n;lg++)
        for(ll x=1;x<=m;x++)
    {
        ll val=(pw[m-x][lg-2]*pw[m][n-lg])%mod;
        val=(val*(n-lg+1))%mod;
        ans-=val;
        if(ans<0)
            ans+=mod;
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define fr(i,n) for(int i = 0; i<n; i++)
#define sz(v) (int)(v.size())
#define prin(a) cout << #a << " = " << a << endl
#define prinv(v) cout << #v << " = "; for(auto it : v) cout << it << ", "; cout << endl
#define all(v) (v).begin(),(v).end()

typedef long long ll;

#define rmin(a,b) a = min<ll>(a,b)
#define rmax(a,b) a = max<ll>(a,b)

#define fi first
#define se second

const int N = 2e5+10;
ll a[N], b[N], p[N];
ll dono[N];

void no(){
	cout << -1 << "\n";
	exit(0);
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	ll n; cin >> n;
	fr(i,n) cin >> a[i];
	fr(i,n) cin >> b[i];
	fr(i,n) cin >> p[i], p[i]--;
	fr(i,n) dono[p[i]] = i;

	fr(i,n) if(p[i]!=i and b[p[i]]>=a[i]) no();

	vector<pair<ll,ll>> vp;
	fr(i,n) vp.emplace_back(a[i],i);
	sort(all(vp));
	vector<pair<ll,ll>> ans;
	for(auto &[peso,ia] : vp){
		if(p[ia]==ia) continue;
		ll iq = dono[ia];
		ans.emplace_back(ia,iq);
		swap(p[ia],p[iq]);
		dono[p[ia]] = ia;
		dono[p[iq]] = iq;
	}
	cout << sz(ans) << "\n";
	for(auto &[i,j] : ans){
		cout << i+1 << " " << j+1 << "\n";
	}
}

/*
"An anomaly, I'm Muhammad Ali
  Cause I know one day I'm gonna be the"
                - Greatest, Eminem
*/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;

int main(){
    Shazam;
    int n; cin >> n;
    vector<pair<int,int>> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i].ff >> b[i].ff;
        a[i].ss = b[i].ss = i;
    }
    sort(all(a));
    sort(all(b));
    if(a.front().ss != b.front().ss){
        cout << max(a[0].ff , b[0].ff) << endl;
    }
    else{
        cout << min({a[0].ff + b[0].ff, max(a[1].ff ,b[0].ff), max(a[0].ff , b[1].ff)}) << endl;
    }
    return 0;
}