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

int main() {
  ll b, c;
  cin >> b >> c;

  ll ans = 0;
  if (b > 0) {
    ll l1 = b - c / 2;
    ll r1 = b + (c - 2) / 2;
    ll l2 = -b - (c - 1) / 2;
    ll r2 = -b + (c - 1) / 2;

    ans += r1 - l1 + 1;
    ans += r2 - l2 + 1;

    if (l1 <= r2) ans -= r2 - l1 + 1;
  }
  else {
    ll l1 = b - c / 2;
    ll r1 = b + (c - 2) / 2;
    ll l2 = -b - (c - 1) / 2;
    ll r2 = -b + (c - 1) / 2;

    ans += r1 - l1 + 1;
    ans += r2 - l2 + 1;

    if (l2 <= r1) ans -= r1 - l2 + 1;
  }

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class T> int lwb(const V<T>& v, const T& a){return lower_bound(all(v),a) - v.begin();}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	ll x,c; cin >> x >> c;
	ll p = x-c/2, q = max(x,x+c/2-1);
	ll r = (-x-(c-1)/2), s = (-x+(c-1)/2);
	cout << (q-p+1) + (s-r+1) - max(min(q,s)-max(p,r)+1,0LL) << endl;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;

    string h;
    cin >> h;
    for(int i=0;i<a;i++){
    if(h.at(i)=='x'){
      if(b>0){
      b--;
      }
      else{
        b=0;
      }
    }
    else if(h.at(i)=='o'){
      b++;
    }

  }
  if(b<=0){
    cout << 0 << endl;
    return 0;
  }
  else if(b>0){
    cout << b << endl;
    return 0;
  }
}

#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  endl           "\n"
#define  pb             push_back
#define  sym(s)         s="#"+s+"#";
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());

typedef  long long             ll;
typedef  unsigned long long    ull;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   N  =  3e+5+7;

vll adj[N];ll vis[N]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n,x;
string s;
//<<-----Implement Functions Here---->>//

//<<-----Start of Main--------------->>//
void MAIN(){
        cin>>n>>x>>s;sym(s);
        for(ll i=1;i<=n;i++){
            if(s[i]=='o')x++;
            else if(s[i]=='x'&&x>0)x--;
        }
        cout<<x<<endl;
}

int main(){
    fastio;randomINIT;

    //cin>>t;
    while(t--){
        MAIN();
    }

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}


#include <bits/stdc++.h>

#define int int64_t

const int N=1e5+9, N2=2e5+9;

using namespace std;

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

	int n, q;
	string s,c;

	cin >> n >> s >> q;
	c=s.substr(n,n);
	s.erase(n,n);

	for (int i=0; i<q; i++){
		int t, a, b;

		cin >> t >> a >> b;

		if (t==1){
			a--,b--;

			if (b<n){
				swap(s[a],s[b]);
			}
			else if (a>=n){
				swap(c[a-n],c[b-n]);
			}
			else {
				swap(s[a],c[b-n]);
			}
		}
		else {
			swap(s,c);
		}

		//cout << s << '\n';
	}

	cout << s << c	;
}

#include<bits/stdc++.h>
#define ll long long
#define re register
#define INF 2147483647
using namespace std;

inline int read()
{
	int f=1,x=0;char s=getchar();
	while(s<'0'||s>'9')
	{
		if(s=='-') f=-1;
		s=getchar();
	}
	while(s>='0'&&s<='9')
	{
		x=x*10+s-48;
		s=getchar();
	}
	return f*x;
}

map<string,int> m1,m2;
string s[200005];

int main()
{
	ios::sync_with_stdio(false);
	int n=read();
	for(int i=1;i<=n;i++)
	{
		char str[20];
		scanf("%s",str);
		s[i]=str;
	}
	for(int i=1;i<=n;i++)
		if(s[i][0]!='!') m1[s[i]]++;
	for(int i=1;i<=n;i++)
		if(s[i][0]=='!') m2[s[i]]++;
	string res="!";
	for(int i=1;i<=n;i++)
		if(s[i][0]!='!')
		{
          //cout<<m1[s[i]]<<" "<<m2[res+s[i]]<<endl;
			if(m1[s[i]]&&m2[res+s[i]])
			{
				cout<<s[i];
				return 0;
			}
		}
	printf("satisfiable");
	return 0;
}


#include "bits/stdc++.h"

#define all_of(x) std::begin(x), std::end(x)
#ifdef _GLIBCXX_DEBUG
    #define debug(x) cerr << #x << ": " << x << endl
#else
    #define debug(x)
#endif

using namespace std;

using LL = long long;

template<typename T>
ostream& operator << (ostream& out, const vector<T>& v) {
    out << "[";
    for(const auto& x : v) {
        out << x << ", ";
    }
    return out << "]";
}
template<typename T>
istream& operator >> (istream& in, vector<T>& v) {
    for(auto& x : v) {
        in >> x;
    }
    return in;
}

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

int N;
vector<int> A, B;

int memo[200][200];
bool solve(int n, int f) {
    if(memo[n][f] != -1) {
        return memo[n][f];
    }
    if(n == N) {
        return memo[n][f] = (f == 0);
    }
    if(f == N - n) {
        return memo[n][f] = true;
    }
    int M = 0;
    vector<int> A0, B0;
    int is_first = -1;
    for(int i = 0; i < int(A.size()); ++i) {
        if(B[i] != -1 and A[i] >= B[i]) {
            return memo[n][f] = false;
        }
        if((A[i] == -1 or A[i] >= 2 * n) and (B[i] == -1 or B[i] >= 2 * n)) {
            A0.push_back(A[i]);
            B0.push_back(B[i]);
            ++M;
            if(A[i] == 2 * n) {
                is_first = M - 1;
            }
        }
    }
    if(M + f != N - n) {
        return memo[n][f] = false;
    }
    auto foo = [&](int i, int a, int b) {
        int c = b + b - a;
        if(b <= a or c > 2 * N) {
            return false;
        }
        vector<bool> V(b - a, false);
        V[0] = true;
        for(int m = 0; m < M; ++m) {
            if(m == i) {
                continue;
            }
            if((a <= A0[m] and A0[m] < c) or (a <= B0[m] and B0[m] < c)) {
                if(A0[m] != -1) {
                    if(B0[m] != -1 and B0[m] - A0[m] != b - a) {
                        return false;
                    }
                    if(A0[m] >= b or V[A0[m] - a]) {
                        return false;
                    }
                    V[A0[m] - a] = true;
                } else {
                    if(B0[m] < b or V[B0[m] - b]) {
                        return false;
                    }
                    V[B0[m] - b] = true;
                }
            }
        }
        int f0 = f;
        for(auto x : V) {
            if(not x) {
                --f0;
            }
        }
        if(f0 < 0) {
            return false;
        }
        return solve(c / 2, f0);
    };
    if(is_first >= 0) {
        if(B0[is_first] != -1) {
            return memo[n][f] = foo(is_first, 2 * n, B0[is_first]);
        } else {
            for(int b = A0[is_first] + 1; b < 2 * N; ++b) {
                if(foo(is_first, 2 * n, b)) {
                    return memo[n][f] = true;
                }
            }
            return memo[n][f] = false;
        }
    } else {
        for(int i = 0; i < M; ++i) {
            if(A0[i] == -1) {
                if(foo(i, 2 * n, B0[i])) {
                    return memo[n][f] = true;
                }
            }
        }
        if(f > 0) {
            --f;
            for(int b = 2 * n + 1; b < 2 * N; ++b) {
                if(foo(-1, 2 * n, b)) {
                    return memo[n][f + 1] = true;
                }
            }
            return memo[n][f + 1] = false;
        }
        return memo[n][f] = false;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    memset(memo, -1, sizeof(memo));

    cin >> N;
    int free_cnt = 0;
    for(int n = 0; n < N; ++n) {
        int a, b;
        cin >> a >> b;
        if(a == -1 and b == -1) {
            ++free_cnt;
        } else {
            A.push_back(max(-1, a - 1));
            B.push_back(max(-1, b - 1));
        }
    }

    cout << ((solve(0, free_cnt)) ? ("Yes") : ("No")) << "\n";

    return 0;
}

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

bool between(int x, int lo, int hi) {
	return lo <= x && x < hi;
}

bool check(int lo, int n, vector<pair<int,int>> &recs) {

	if(lo == n) {
		return true;
	}

	for(auto c : range(1, n + 1)) {

		int mid = lo + c;
		int hi = lo + c * 2;
		if(hi > n) {
			break;
		}

		bool ok = true;
		vector<int> spaces(c);

		for(auto& rec : recs) {
			int a = rec.first;
			int b = rec.second;
			if(!between(a, lo, hi) && !between(b, lo, hi)) {
				continue;
			}
			if(a < 0) {
				a = b - c;
			}
			if(b < 0) {
				b = a + c;
			}
			bool bad = (b - a != c) || !between(a, lo, mid) || !between(b, mid, hi) || spaces[a - lo];
			if(bad) {
				ok = false;
				break;
			}
			spaces[a - lo] = true;
		}

		if(ok && check(hi, n, recs)) {
			return true;
		}
	}

	return false;
}

int main() {

	const int N = read_item();
	vector<pair<int,int>> recs(N);
	for(auto i : range(N)) {
		recs[i].first = (int)read_item() - 1;
		recs[i].second = (int)read_item() - 1;
	}

	bool ok = check(0, 2 * N, recs);
	printf("%s\n", ok ? "Yes" : "No");

	return 0;
}

/* wafdayo~~~ */


// 4 3 2 1
//
// ( = +1
// ) = -1
// >= 0 every time
// == 0 at the end

#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define int long long
#define FOR(i, a, b) for (int i = (a), _##i = (b); i <= _##i; ++i)
#define FORD(i, a, b) for (int i = (a), _##i = (b); i >= _##i; --i)
#define REP(i, a) for (int i = 0, _##i = (a); i < _##i; ++i)

#define DEBUG(X) { auto _X = (X); cerr << "L" << __LINE__ << ": " << #X << " = " << (_X) << endl; }
#define PR(A, n) { cerr << "L" << __LINE__ << ": " << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << endl; }
#define PR0(A, n) { cerr << "L" << __LINE__ << ": " << #A << " = "; REP(_, n) cerr << A[_] << ' '; cerr << endl; }

#define __builtin_popcount __builtin_popcountll
#define SZ(x) ((int)(x).size())
#define ALL(a) (a).begin(), (a).end()
#define TWO(x) (1LL<<(x))
inline int gcd(int a, int b) {int r; while (b) {r = a % b; a = b; b = r;} return a;}

// for 64-bit, use mt19937_64
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// use shuffle instead of random_shuffle
#define random_shuffle askcjaljc

const int MN = 400111;
int a[MN];
pair<int,int> b[MN];

int32_t main() {
    ios::sync_with_stdio(0);
    int n; cin >> n;
    n *= 2;
    FOR(i,1,n) {
        cin >> a[i];
        b[i] = {a[i], i};
    }
    sort(b+1, b+n+1);
    FOR(i,1,n/2) a[b[i].second] = 0;
    FOR(i,n/2+1,n) a[b[i].second] = 1;

    int sum = 0;
    int open = -1;
    FOR(i,1,n) {
        if (sum == 0) {
            open = a[i];
            sum++;
            cout << '(';
            continue;
        }

        if (a[i] == open) {
            cout << '(';
            sum++;
            continue;
        }

        cout << ')';
        --sum;
    }
    cout << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

bool solve(string &S) {
    if (S.size() <= 5) {
        sort(S.begin(), S.end());
        do {
            int val = 0;
            for (auto c : S) val = val * 10 + (int)(c-'0');
            if (val % 8 == 0) return true;
        } while (next_permutation(S.begin(), S.end()));
        return false;
    }
    vector<int> num(10, 0);
    for (const auto c : S) num[c-'0']++;
    for (int i = 0; i < 1000; i += 8) {
        vector<int> simo(10, 0);
        int i2 = i;
        for (int iter = 0; iter < 3; ++iter) {
            simo[i2 % 10]++;
            i2 /= 10;
        }
        if (simo[0]) continue;
        bool ok = true;
        for (int v = 0; v < 10; ++v) if (simo[v] > num[v]) ok = false;
        if (ok) return true;
    }
    return false;
}

int main() {
    string S;
    while (cin >> S) {
        if (solve(S)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug true
#define debug2 false

class unionfind{
    /*
    Copyright (c) 2020 0214sh7
    https://github.com/0214sh7/library/
    */
    private:
    std::vector<int> UF,rank;
    public:

    void init(int N){
        UF.clear();
        rank.clear();
        for(int i=0;i<N;i++){
            UF.push_back(i);
            rank.push_back(0);
        }
    }

    int root(int k){
        if(UF[k]==k){
            return k;
        }else{
            UF[k]=root(UF[k]);
            return UF[k];
        }
    }

    bool same(int p,int q){
        return root(p)==root(q);
    }

    void unite(int P,int Q){
        int p=root(P);
        int q=root(Q);
        if(p==q)return;
        if(rank[p]<rank[q])std::swap(p,q);
        UF[q]=p;
        if(rank[p]==rank[q])rank[p]++;
    }

};

int main(void){
    ll H,W;
    vector<string> S;
    cin >> H >> W;
    REP(i,H){
        string s;
        cin >> s;
        S.push_back(s);
    }

    if(H<=2 || W<=2){
        cout << 0 << endl;
        return 0;
    }

    unionfind UF;
    UF.init(H+W-3);

    //0:外周
    //1~H-2:横線
    //H-1~H+W-4:縦線

    for(ll i=1;i<H-1;i++){
        if(S[i][0]=='#' || S[i][W-1]=='#'){
            UF.unite(0,i);
        }
    }

    for(ll j=1;j<W-1;j++){
        if(S[0][j]=='#' || S[H-1][j]=='#'){
            UF.unite(0,H-2+j);
        }
    }

    for(ll i=1;i<H-1;i++){
        for(ll j=1;j<W-1;j++){
            if(S[i][j]=='#'){
                UF.unite(i,H-2+j);
            }
        }
    }

    set<ll> Y,X;
    Y.insert(UF.root(0));
    X.insert(UF.root(0));
    for(ll i=1;i<H-1;i++){
        Y.insert(UF.root(i));
    }
    for(ll i=H-1;i<H+W-3;i++){
        X.insert(UF.root(i));
    }

    ll R=Y.size()-1,C=X.size()-1;

    //cout << R MM C << endl;
    cout << min(R,C) << endl;

    return 0;
}

#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>
#include <functional>
#include <cassert>
//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using ld = long double;
using vld = vector<ld>;
using vb = vector<bool>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}
template <class T> ostream& operator<<(ostream& s, const vector<T>& a) { for(auto i : a) s << i << ' '; return s; }

constexpr ll INFL = 1LL << 60;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

struct mint {
    static const long long mod = 998244353;
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint& a) {if ((x += a.x) >= mod) x -= mod; return *this;}
    mint& operator-=(const mint& a) {if ((x += mod - a.x) >= mod) x -= mod; return *this;}
    mint& operator*=(const mint& a) {(x *= a.x) %= mod; return *this;}

    friend const mint operator+(const mint& a, const mint& b) { mint ret = a; return ret += b; }
    friend const mint operator-(const mint& a, const mint& b) { mint ret = a; return ret -= b; }
    friend const mint operator*(const mint& a, const mint& b) { mint ret = a; return ret *= b; }
    friend ostream& operator<<(ostream& s, const mint& a) { return s << a.x; }

    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2);}
    mint& operator/=(const mint a) { return (*this) *= a.inv();}
    friend const mint operator/(const mint& a, const mint& b) { mint ret = a; return ret /= b; }
};

void solve() {
    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h, string(w, '.'));
    rep(i, k) {
        ll h_, w_;
        char c_;
        cin >> h_ >> w_ >> c_;
        s[h_-1][w_-1] = c_;
    }
    /*
    rep(i, h) {
        rep(j, w) cout << s[i][j] << ' ';
        cout << endl;
    }
    */
    using vm = vector<mint>;
    vector<vm> dp(h, vm(w));
    dp[0][0] = mint(3).pow(h*w-k);
    mint inv3 = mint(3).inv();
    rep(i, h) rep(j, w) {
        if(i > 0) {
            if(s[i-1][j] == '.') dp[i][j] += dp[i-1][j] * 2 * inv3;
            else if(s[i-1][j] == 'D' || s[i-1][j] == 'X') dp[i][j] += dp[i-1][j];
        }
        if(j > 0) {
            if(s[i][j-1] == '.') dp[i][j] += dp[i][j-1] * 2 * inv3;
            else if(s[i][j-1] == 'R' || s[i][j-1] == 'X') dp[i][j] += dp[i][j-1];
        }
    }
    cout << dp[h-1][w-1] << endl;
    /*
    rep(i, h) {
        rep(j, w) cout << dp[i][j] << ' ';
        cout << endl;
    }
    */
    return;
}

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


/*
Arthor: Ender_zzm
E-mail: zzm_ender_wiggin@outlook.com
Blog: oi.ender-zzm.pro
*/

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

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
template <class T>
T read(){
    register T x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10);
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl;
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)

const int maxn = 201;

int n;
int dp[maxn][maxn];
int a[maxn], b[maxn];
int vis[maxn], match[maxn];
int check(int l, int r) {
	for (int i = l, j = (l + r + 1) / 2; j <= r; j++, i++) {
		if (vis[i] == 2 || vis[j] == 1) return 0;
		//debug(match[i]); debug(match[j]);
		if (match[i] && match[j] && match[i] != match[j]) return 0;
	//	if (match[i] != match[j]) return 0;
	}
	return 1;
}
int main() {
	n = read<int>();
	For (i, 1, n) {
		a[i] = read<int>(), b[i] = read<int>();
		if ((~a[i] && vis[a[i]]) || (~b[i] && vis[b[i]]) || (~a[i] && ~b[i] && a[i] >= b[i])) {
			puts("No"); return 0;
		}
		if (~a[i]) vis[a[i]] = 1, match[a[i]] = i;
		if (~b[i]) vis[b[i]] = 2, match[b[i]] = i;
	}
	for (int len = 2; len <= 2 * n; len += 2) {
		for (int l = 1, r = l + len - 1; l <= 2 * n && r <= 2 * n; l += 2, r += 2) {
			for (int k = l + 1; k < r; k += 2) {
				dp[l][r] |= (dp[l][k] & dp[k + 1][r]);
				if (dp[l][r]) break;
			}
			if (dp[l][r]) continue;
			dp[l][r] = check(l, r);
		}
	}
	if (dp[1][2 * n]) printf("Yes");
	else puts("No");
	return 0;
}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

/**
 * 近距離にあるペアが一組あるだけで他の全ての面積が小さくなってしまう
 * →企業毎に面積を変えられるようにする
 * */

struct Request {
  int id;
  int x, y;
  int r;
};

struct Answer {
  int x0, y0, x1, y1;
};

constexpr int FIELD_MAX = 10'000;

void solve(vector<Request>& req, vector<Answer>& ans) {
  for (const auto& r : req) {
    auto& a = ans[r.id];
    a.x0 = r.x;
    a.y0 = r.y;
    a.x1 = r.x + 1;
    a.y1 = r.y + 1;
  }

  int seed = 1;
  mt19937 rng(seed);

  array<int, 4> actions = {0, 1, 2, 3};
  queue<int> q;
  rep(i, ans.size()) { q.push(i); }

  while (!q.empty()) {
    int id = q.front();
    q.pop();

    auto& a = ans[id];

    shuffle(actions.begin(), actions.end(), rng);
    for (const int action : actions) {
      Answer new_region = {.x0 = a.x0 + (action == 0 ? -1 : 0),
                           .y0 = a.y0 + (action == 1 ? -1 : 0),
                           .x1 = a.x1 + (action == 2 ? 1 : 0),
                           .y1 = a.y1 + (action == 3 ? 1 : 0)};

      bool valid_region = (new_region.x0 >= 0 && new_region.x1 <= FIELD_MAX &&
                           new_region.y0 >= 0 && new_region.y1 <= FIELD_MAX);
      if (!valid_region) {
        continue;
      }

      bool ok = true;
      rep(i, ans.size()) {
        if (i != id) {
          const auto& other = ans[i];
          bool overlap =
              !(new_region.x1 <= other.x0 || new_region.x0 >= other.x1 ||
                new_region.y1 <= other.y0 || new_region.y0 >= other.y1);
          ok = (ok && !overlap);
        }
      }
      if (ok) {
        a = new_region;
        q.push(id);
        break;
      }
    }
  }
}

int main() {
  int N;
  cin >> N;

  vector<Request> req(N);
  rep(i, N) {
    auto& r = req[i];
    r.id = i;
    cin >> r.x >> r.y >> r.r;
  }

  vector<Answer> ans(N);

  solve(req, ans);

  rep(i, N) {
    const auto& a = ans[i];
    cout << a.x0 << " " << a.y0 << " " << a.x1 << " " << a.y1 << endl;
  }

  return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << '\n'
typedef long long ll;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
//const ll MOD = 998244353;

template <typename T> inline bool chmax(T &a, T b) {return a < b ? a = b, true : false;}
template <typename T> inline bool chmin(T &a, T b) {return a > b ? a = b, true : false;}

void solve() {
    int n;  cin >> n;
    vector<ll> a(n);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        ans ^= a[i];
    }
    for(int i = 0; i < 1 << (n - 1); i++){
        ll tx = 0;
        ll tmp = a[0];
        for(int j = 0; j < n - 1; j++){
            if(i & 1 << j){
                tmp |= a[j + 1];
            }else{
                tx ^= tmp;
                tmp = a[j + 1];
            }
        }
        tx ^= tmp;
        chmin(ans, tx);
    }
    print(ans);
}

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

    int t;
    //cin >> t;
    t = 1;
    while(t--) solve();
    return 0;
}

#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,a,n) for(int i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.push_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }
template<typename T, typename... Args>
inline void __evars(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __evars_out_var(a);
    cerr << "; ";
    __evars(++it, args...);
}
template<typename T_vector>
void output_vector(const T_vector &v, bool add_one = false, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());

    for (int i = start; i < end; i++)
        cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
template<class T, class H>using umap=unordered_map<T,H,custom_hash>;
template<class T>using uset=unordered_set<T,custom_hash>;
  map<char, char> near;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fio;
    clock_t clk = clock();
    int t = 1;
    // cin >> t;
    while(t--)
    {
        long double n;
        cin >> n;
        long double ans = 0.0;
        for(int i = 1; i < n; i++)
        {
            ans += n / (n - i);
        }
        cout << fixed << setprecision(10);
        cout << ans << endl;
    }
    cerr << '\n'<<"Time (in s): " << double(clock() - clk) * 1.0 / CLOCKS_PER_SEC << '\n';
}


//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;

using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;

const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);

//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l, int r) { return uniform_int_distribution<int> (l, r)(rng); }

int n;
double D, H, h[111], d[111];
bool can(double x) {
  fo(i, 1, n, 1) {
    double slope = (H - x) / D;
    double he = x + (d[i] * slope);
    if (h[i] > he) return 0;
  }
  return 1;
}
main() {
  file("paint");
  ios;
  cin >> n >> D >> H;
  fo(i, 1, n, 1) cin >> d[i] >> h[i];
  double l = 0, r = H;
  while (r - l > EPS)  {
    can(md) ? r = md : l = md;
  }
  cout << fixed << setprecision(12) << md;
  return 0;
}
/**

*/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define mod 1000000007

// templates
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define po(x, y) fixed << setprecision(y) << x
#define ss(s) scanf(" %[^\n]%*c", s)
#define sc(n) scanf("%d", &n)
#define sl(n) scanf("%lld", &n)
#define ps(s) printf("%s\n", s)
#define pr(n) printf("%d\n", n)
#define pl(n) printf("%lld\n", n)
#define prs(n) printf("%d ", n)
#define pls(n) printf("%lld ", n)
using namespace std;

const ll inf = (ll)1e15 + 10;
const int N = (int)1e6 + 10;

void solve() {
  int N, D, H;
  sc(N), sc(D), sc(H);
  vector<pair<int, int>> v;
  for (int i = 0; i < N; i++) {
    int d, h;
    sc(d), sc(h);
    v.push_back({d, h});
  }
  double mx = 0.0;
  for (auto x : v) {
    double temp = ((H - x.S) * 1.0 * D) / ((D - x.F));
    mx = max(mx, H - temp);
  }
  printf("%0.6f", mx);
}

int main() {
  // #ifndef ONLINE_JUDGE
  // 	freopen("input.txt", "r", stdin);
  // 	freopen("output.txt", "w", stdout);
  // #endif
  int t = 1;
  // sc(t);
  while (t--) {
    solve();
  }
  //	cerr << (float)clock() / CLOCKS_PER_SEC * 1000 << " ms" << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++)
#define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--)
#define all(v) v.begin(), v.end()
void chmax(ll &x, ll y) {x = max(x,y);}
void chmin(ll &x, ll y) {x = min(x,y);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}
template<class in_Cout> void Cout(in_Cout x) {cout << x << endl; exit(0);}
template<class in_vec_cout>
void vec_cout(vector<in_vec_cout> vec) {
    for (in_vec_cout res : vec) {cout << res << " ";}
    cout << endl;
}

const ll inf = 1e18;
const ll mod = 1e9 + 7;

int main() {
    vector<ll> A(3);
    rep(i,3) cin >> A[i];
    ll N = A.size();
    vector<ll> num(N);
    rep(i,N) num[i] = i;
    do {
        vector<ll> tmp(N);
        rep(i,N) tmp[i] = A[num[i]];
        if (tmp[2]-tmp[1]==tmp[1]-tmp[0]) Yes();
    } while (next_permutation(all(num)));
    No();
}

#include<bits/stdc++.h>
using namespace std;
int a[10];
int main()
{
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[1]-a[0]==a[2]-a[1])
	{
		cout<<"Yes";
	}
	else
	cout<<"No";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch RemoveIt | diff RemoveIt.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address RemoveIt.cpp && ./a.out

/*

 2/6/2021

 4:03-

 */

const int MAX_N=1e6+1;
LL A[MAX_N],X;
int N;

void solve() {
  vector<LL> as;
  REP(i,N) if(A[i]!=X) as.push_back(A[i]);
  REP(i,SZ(as)) cout<<as[i]<<" ";
  cout<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N>>X;
  REP(i,N) cin>>A[i];
  solve();

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using vi  = vector<int64_t>;
using vvi = vector<vi>;
using pii = pair<int64_t, int64_t>;
int INF = 1e9;

int main() {
  char s, t;
  cin >> s >> t;

  if (s == 'Y') {
    t = toupper(t);
    cout << t << endl;
  } else {
    cout << t << endl;
  }
}


#include <cstdio>
#include <algorithm>
using namespace std;
#define int long long
#define mod 998244353
#define maxn 200005
int n, ret, cnt;
int a[maxn], sum[maxn];

int qkpow( int x, int y ) {
	int ans = 1;
	while( y ) {
		if( y & 1 ) ans = ans * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return ans;
}

signed main() {
	scanf( "%lld", &n );
	for( int i = 1;i <= n;i ++ )
		scanf( "%lld", &a[i] ), ret = ( ret + a[i] * a[i] % mod ) % mod;
	sort( a + 1, a + n + 1 );
	for( int i = n;i;i -- )
		sum[i] = sum[i + 1] + a[i];
	for( int i = 3;i <= n;i ++ )
		cnt = ( cnt + qkpow( 2, i - 2 ) * a[i] % mod ) % mod;
	for( int i = 1;i <= n;i ++ ) {
		ret = ( ret + a[i] * ( cnt + a[i + 1] ) % mod ) % mod;
		cnt = ( cnt * qkpow( 2, mod - 2 ) % mod - a[i + 2] + mod ) % mod;
	}
	printf( "%lld\n", ret );
	return 0;
}

#include<iostream>
#include<array>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<int mod>
struct ModInt {
    long long x;
    static constexpr int MOD = mod;

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

    explicit operator int() const {return x;}

    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; }
    ModInt operator%(const ModInt &p) const { return ModInt(0); }

    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;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt power(long long n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1)
            ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    ModInt power(const ModInt p) const{
        return ((ModInt)x).power(p.x);
    }

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

using modint = ModInt<mod>;

int n,m;
modint dp[5010][5010];

void solve(){
    cin >> n >> m;
    Rep(i,1,m+1) {
        dp[0][i]=1;
        dp[1][i]=m-1;
    }
    modint pow1=1;
    Rep(i,1,n){
        pow1*=(modint)m;
        Rep(j,1,m+1){
            dp[i+1][j]=dp[i][j]*(modint)(m-j)+pow1*(modint)(j-1);
        }
    }
    modint ans=0,pow2=1;
    per(i,n){
        Rep(j,1,m+1){
            //cout << i << " " << j << " " << dp[i][j]*pow2 << endl;
            ans+=dp[i][j]*pow2;
        }
        pow2*=(modint)m;
    }
    cout << ans << endl;
}

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


/**
*    author:  shu8Cream
*    created: 06.03.2021 11:57:11
**/

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi x(n),y(n),r(n);
    rep(i,n) cin >> x[i] >> y[i] >> r[i];
    rep(i,n){
        printf("%d %d %d %d\n", x[i],y[i],x[i]+1,y[i]+1);
    }
}

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

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> A(N), B(M);
  for (int& x : A) cin >> x;
  for (int& x : B) cin >> x;

  vector<int> C;
  set_symmetric_difference(A.begin(), A.end(),
                           B.begin(), B.end(),
                           back_inserter(C));

  for (int x : C) cout << x << ' ';
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	string a,s;
    cin>>a>>s;
    if(a[0]=='Y'){
        cout<<(char)(s[0]+'Z'-'z');
    }else{
        cout<<s[0]<<endl;
    }
}

#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
int main() {
    string s,t;
    cin >> s >> t;
    if(s == "Y"){
        t = toupper(t[0]);
        cout << t << endl;
    }else{
        cout << t << endl;
    }
    return 0;
}


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

long long int func(long long int x)
{
    long long int val1=0;
    long long int val2=0;
    string s="";
    while(x>0)
    {
        int temp=x%10;
        s.push_back(temp+'0');
        x/=10;
    }

    sort(s.begin() , s.end());
   // cout<<s<<endl;
    long long int ten=1;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        val1 += ten*(s[i] - '0');
        ten*=10;
    }

    reverse(s.begin(),s.end());

    ten=1;

    for(int i=0;i<n;i++)
    {
        val2 += ten*(s[i] - '0');
        ten*=10;
    }

    return (val1 - val2);

}
int main()
{

     int test;
     test=1;
     while(test--)
     {

        long long int n,k;
        cin>>n>>k;

        for(int i=1;i<=k;i++)
        {
            long long int val=func(n);
            n=val;
           // cout<<val<<endl;

        }

        cout << n<<endl;

     }

	return 0;
}

/*************************************************************************
    > File Name: C.cpp
    > Author: Bran
    > Mail: 1811161330@qq.com
    > Created Time: 2021/1/30 20:29:30
 ************************************************************************/

#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define fr first
#define sc second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define rep(i,x,n) for (int i = x; i < int(n); ++i)

using namespace std;
using LL = long long;
const double PI = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;

void solve() {
        int n, m;
        cin >> n >> m;
        vector<pii> condition(m);
        rep(i, 0, m) {
                cin >> condition[i].fr >> condition[i].sc;
                --condition[i].fr, --condition[i].sc;
        }
        int k;
        cin >> k;
        vector<pii> dish(k);
        rep(i, 0, k) {
                cin >> dish[i].fr >> dish[i].sc;
                --dish[i].fr, --dish[i].sc;
        }
        int res = 0;
        for (int i = 0; i < (1 << k); ++i) {
                vector<int> cnt(n, 0);
                rep(j, 0, k) {
                        if ((i >> j) & 1) ++cnt[dish[j].sc];
                        else ++cnt[dish[j].fr];
                }
                int ans = 0;
                rep(j, 0, condition.size())
                        if (cnt[condition[j].fr] && cnt[condition[j].sc]) {
                                ++ans;
                        }
                res = max(res, ans);
        }
        cout << res << endl;
}

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


#include<bits/stdc++.h>

#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9+10
#define INFL 1e18
//#define mod 1000000007
#define mod 998244353

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//cout<< fixed << setprecision(10)
//__builtin_popcountll()
//max no of prime factor 5*1e5=7, 1e6=8, 1e9=10;

int main()
{
    fast;
    int n,m,i,j;
    cin>>n>>m;
    string s[n];
    for(i=0;i<n;i++)
        cin>>s[i];
    ll ans=1;
    ll f[n+m+10][4];
    mem(f,0);
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            f[i+j][0]++;
            if(s[i][j]=='R')
                f[i+j][1]++;
            if(s[i][j]=='B')
                f[i+j][2]++;
            if(s[i][j]=='.')
                f[i+j][3]++;

        }
    }

    for(i=0;i<n+m-1;i++)
    {
        if(f[i][1]!=0&&f[i][2]!=0)
        {
            cout<<0<<"\n";
            return 0;
        }

        if(f[i][0]==f[i][3])
        {
            ans=ans*2;
            ans=ans%mod;
            continue;
        }

    }
    cout<<ans<<"\n";

}

#include<bits/stdc++.h>
#define rep(i,a,b) for(R int i=a;i<=b;i++)
#define R register
#define endl putchar('\n')
const int N=1005;
const long long mod=998244353;
using namespace std;

int n,m;
long long ans=1;
char s[N][N];

void solve() {
	rep(sm,2,n+m) {
		int r=0,b=0;
		if(sm<=m+1) {
			rep(i,1,sm-1) {
				int j=sm-i;
				r|=s[i][j]=='R';
				b|=s[i][j]=='B';
			}
		} else {
			rep(i,sm-m,n) {
				int j=sm-i;
				r|=s[i][j]=='R';
				b|=s[i][j]=='B';
			}
		}
		if(r&&b) { printf("0"),exit(0); }
		else if(!r&&!b) (ans*=2ll)%=mod;
	}
}

int main() {
	scanf("%d%d",&n,&m);
	rep(i,1,n) scanf("%s",s[i]+1);
	solve();
	printf("%lld",ans);
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N),mod_200(N);
    for(int n=0;n<N;n++) cin >> A[n];

    for(int n=0;n<N;n++) mod_200[n] = A[n]%200;
    vector<long long> num_pairs(200,0);
    for(int n=0;n<N;n++) num_pairs[mod_200[n]]++;
    long long ans = 0;
    for(int i=0;i<200;i++){
        if(num_pairs[i]>1){
            ans += (num_pairs[i]-1)*(num_pairs[i])/2;
        }
    }
    cout << ans << endl;
    return 0;
}

#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 <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

void solve() {
    int n;
    cin >> n;
    int cnt[200] = {0};
    ll ans = 0;
    fori (i, 0, n) {
        int x;
        cin >> x;
        int m = x % 200;
        ans += cnt[m];
        cnt[m]++;
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T>, greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

/**
* Binary_Indexed_Tree(BIT)
* Fenwick Tree
* 0-indexed!!!
* O(log N)
*/
template<typename T = int>
class binary_indexed_tree {
private:
    int N;
    std::vector<T> bit;
public:
    binary_indexed_tree() {}
    binary_indexed_tree(int n) : N(n), bit(n, 0) {}
    // bit[point]にnum追加
    void add(int point, T val) {
        point++;

        for (int i = point; i - 1 < N; i += i & (-i)) {
            bit[i - 1] += val;
        }
    }
    // [0, point)
    T sum(int point) {
        T res = 0;
        for (int i = point; i > 0; i -= i & (-i)) {
            res += bit[i - 1];
        }

        return res;
    }
    // [left, right)
    T sum(int left, int right) {
        return this->sum(right) - this->sum(left);
    }
};

void solve() {
    int N;
    cin >> N;
    VT<pair<LL, int>> A(N);
    REP(i, N) {
        cin >> A[i].first;
        A[i].second = i;
    }
    SORT(A);

    binary_indexed_tree<LL> pos(N), neg(N), cnt_pos(N), cnt_neg(N);
    REP(i, N) {
        pos.add(A[i].second, A[i].first);
        cnt_pos.add(A[i].second, 1);
    }

    LL ans = 0;
    REP(i, N) {
        pos.add(A[i].second, -A[i].first);
        cnt_pos.add(A[i].second, -1);

        const auto pos_cnt = cnt_pos.sum(A[i].second + 1, N);
        const auto neg_cnt = cnt_neg.sum(A[i].second + 1, N);
        const auto pos_tmp = pos.sum(A[i].second + 1, N);
        const auto neg_tmp = neg.sum(A[i].second + 1, N);

        ans += pos_tmp - A[i].first * pos_cnt;
        ans += A[i].first * neg_cnt - neg_tmp;

        neg.add(A[i].second, A[i].first);
        cnt_neg.add(A[i].second, 1);
    }

    cout << ans << endl;
}

int main(void) {
#ifndef ONLINE_JUDGE
    const auto in_stream = freopen("../in.txt", "r", stdin);
    if (in_stream == nullptr) {
        cerr << "ERROR!" << endl;
        return 1;
    }
#endif

    solve();

#ifndef ONLINE_JUDGE
    fclose(in_stream);
#endif
}

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

int main() {
   long long N;
   cin >> N;
   long long A[N];
   for (int i=0; i<N; i++) cin >> A[i];
   sort(A,A+N);
   long long count=0;
   for (int i=0; i<N; i++) {
       count+=(A[i]*(-N+1+2*i));
   }
   cout << count << endl;
}


#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define FOR(i,n,m) for(int i=n; i<(int)m; i++)
#define ROF(i,n,m) for(int i=n; i>(int)m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define debug true
#define dprintf debug && printf

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1e9+7;
const int MAXN = 2e5+5;

vii G[MAXN];
int col[MAXN];
int n, m;

void dfs(int v, int p = -1, int pc = -1){
    if(col[v]) return;
    if(p == -1) col[v] = 1;
    else if(col[p] != pc) col[v] = pc;
    else col[v] = (pc == n ? 1 : pc + 1);
    for(auto up : G[v]){
        int u = up.F, uc = up.S;
        dfs(u, v, uc);
    }
}

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

    rii(n,m);
    FOR(i,0,m){
        int u, v, c;
        riii(u, v, c); u--, v--;
        G[u].pb({v, c});
        G[v].pb({u, c});
    }

    dfs(0);

    FOR(i,0,n) printf("%d\n", col[i]);

    return 0;
}

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

bool coprime(ll a, ll b) {

    if ( __gcd(a, b) == 1)
        return true;
    else
        return false;
}

int main()
{
    ll N;
    cin >> N;
    ll X[N];

    for (ll i = 0; i < N; i++) {
        cin >> X[i];
    }

    const int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};

	ll result = 1e18;

	for(int bit = 0; bit < (1 << 15); bit++) {
		ll p = 1;
		for(int i = 0; i < 15; i++) {
			if(bit & (1 << i)) p *= primes[i];
		}

        bool e = false;
		for (auto x : X) {
            if(coprime(x, p)) {
                e = true;
                break;
            }
        }

        if (e) {
            continue;
        }

        result = min(p, result);
	}

    cout << result << endl;

}


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

int main(){
  string s;
  cin>>s;
  deque<char> dq;
  bool b=true;
  for(int i=0;i<int(s.size());i++){
    if(s[i]=='R') b=!b;
    else{
      if(b){
        if(!dq.empty()&&dq.back()==s[i]){
          dq.pop_back();
        }else{
          dq.push_back(s[i]);
        }
      }else{
        if(!dq.empty()&&dq.front()==s[i]){
          dq.pop_front();
        }else{
          dq.push_front(s[i]);
        }
      }
    }
  }
  int r=int(dq.size());
  for(int i=0;i<r;i++){
    if(b){
      cout<<dq.front();
      dq.pop_front();
    }else{
      cout<<dq.back();
      dq.pop_back();
    }
  }
}

#include <iostream>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <random>
#include <cassert>

typedef long long ll;
using namespace std;

constexpr ll mod007 = 1000000007;
constexpr ll mod998 = 998244353;

int N, A[20];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int Min = INT_MAX;
	for (int i = 0; i < (1 << N); i++) {
		int X = 0;
		int t = 0;
		for (int j = 0; j < N; j++) {
			if (i & (1 << j)) {
				X ^= t;
				t = A[j];
			}
			else {
				t |= A[j];
			}
		}
		X ^= t;
		Min = min(Min, X);
	}
	cout << Min << endl;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>
#include <unordered_map>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
using LL = long long;

typedef std::pair<int, int> pii;
typedef std::pair<int, double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

const double PI = 3.14159265358979323846264338327950L;
const int mod = 1e9+7;
const ll INF = 1LL<<60;

struct container {
    int bottom, top, id;
    container(int id, int bottom, int top) : top(top), bottom(bottom), id(id) {
    }
};

struct Edge {
    ll to, from, cost;
    Edge(ll to, ll from, ll cost) :to(to), from(from), cost(cost) {}
    Edge(): to(-1), from(-1), cost(0){}
};

struct Data {
    ll cost,val;
    Data(ll cost=0, ll val=0) : cost(cost), val(val){}
    bool operator<(const Data& a) const {
        return cost > a.cost;
    }
};

vector<int> to[200200];

struct edge{
    int a,b,c;
    edge(int a = -1,int b = -1, int c = -1):a(a),b(b),c(c){}
    bool operator<(const edge& a) const {
        return c > a.c;
    }
};

void solve(){

    double a,b;
    cin >> a >> b;
    cout << std::setprecision(32) << 100.0*(a-b)/a;
}

int main() {
    int T = 1;
    // cin >> T;

    while (T--) {
        solve();
        cout << endl;
    }
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}
#ifdef LOCAL
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cerr<<(*i)<<" ";cerr<<endl;}
#else
template<class T>void pv(T a,T b){}
#endif

struct P {
  int r, c;
  P(int r=0, int c=0) : r(r), c(c) {}
};

const int L = 30;

pair<P, P> read_query() {
  int si, sj, ti, tj;
  cin >> si >> sj >> ti >> tj;
  return { P(si, sj), P(ti, tj) };
}
ll query(string path) {
  cout << path << endl;
  ll res;
  cin >> res;
  return res;
}

int main() {

  vector<pair<pair<P, P>, ll>> qa;
  REP(k, 1000) {
    P s, t;
    tie(s, t) = read_query();

    int dr = t.r - s.r;
    int dc = t.c - s.c;
    string path;
    if (dr > 0) path += string(abs(dr), 'D');
    if (dr < 0) path += string(abs(dr), 'U');
    if (dc > 0) path += string(abs(dc), 'R');
    if (dc < 0) path += string(abs(dc), 'L');
    ll b = query(path);
    qa.push_back({ {s, t}, b });
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define ALL(v) v.begin(),v.end()
#define sz(v) (ll)v.size()
const ll INF = 1e18;

// E - Train

ll Ceil(ll a, ll b) {
    if(a%b == 0) return a/b;
    else return (a+b)/b;
}

int main() {
    ll n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<vector<pair<ll, ll>>> G(n+1); //ressya tyoutenn
    vector<ll> t(m), k(m);
    for(ll i = 0; i < m; i++) {
        ll a, b;
        cin >> a >> b;
        G[a].push_back({i, b});
        G[b].push_back({i, a});
        cin >> t[i] >> k[i];
    }
    vector<ll> dis(n+1, INF); // dis[i]:xからiまでの最短経路
    dis[x] = 0;
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;
    pq.push({0, x});
    while(!pq.empty()){
        pair<ll, ll> p = pq.top();
        pq.pop();
        ll v = p.second;
        if(dis[v] < p.first) continue;
        for(auto &e : G[v]){
            if(dis[e.second] > Ceil(dis[v],k[e.first])*k[e.first]+t[e.first]){
                dis[e.second] = Ceil(dis[v],k[e.first])*k[e.first]+t[e.first];
                pq.push({dis[e.second], e.second});
            }
        }
    }
    if(dis[y] == INF) cout << -1 << endl;
    else cout << dis[y] << endl;

    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>

#define P 131

#define lc u << 1
#define rc u << 1 | 1

using namespace std;
typedef long long LL;
typedef pair<LL,int> PII;
const int N = 100010,M = N * 2;
const LL INF = 0x3f3f3f3f3f3f3f3fll;
int h[N],ne[M],e[M],idx;
LL dist[N],w[M],f[M];
bool st[N];
int n,m,x,y;

void add(int a,int b,int c,int d)
{
    e[idx] = b,w[idx] = c,f[idx] = d,ne[idx] = h[a],h[a] = idx ++;
}

LL dijkstra()
{
    memset(dist,0x3f,sizeof dist);
    dist[x] = 0;
    priority_queue<PII,vector<PII>,greater<PII>> q;
    q.push(make_pair(0,x));
    while(q.size())
    {
        auto t = q.top();
        q.pop();
        int ver = t.second;
        LL distance = t.first;
        if(st[ver]) continue;
        st[ver] = true;
        // cout << ver << " "<< distance << endl;
        for(int i = h[ver];~i;i = ne[i])
        {
            int j = e[i];
            if(dist[j] > (distance + f[i] - 1) / f[i] * f[i] + w[i])
            {
                dist[j] = (distance + f[i] - 1) / f[i] * f[i] + w[i];
                q.push(make_pair(dist[j],j));
            }
        }
    }
    if(dist[y] >= INF) return -1;
    return dist[y];
}

void solve()
{
    scanf("%d%d%d%d",&n,&m,&x,&y);
    memset(h,-1,sizeof h);
    while(m --)
    {
        int a,b,t,k;
        scanf("%d%d%d%d",&a,&b,&t,&k);
        add(a,b,t,k);
        add(b,a,t,k);
    }
    printf("%lld\n",dijkstra());
}

int main()
{
    #ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #else
    #endif // LOCAL
    int T = 1;
    // init();
    // scanf("%d",&T);
    while(T --)
    {
        // scanf("%lld%lld",&n,&m);
        solve();
        // test();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
using Graph = vector<vector<ll>>;
const long long INF = 1LL<<60;
const long long MOD = 1000000007;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;cin>>n;
    long double a,b,c,d;
    cin>>a>>b>>c>>d;
    long double m1,m2;
    m1=(a+c)/2;
    m2=(b+d)/2;
    long double l=sqrt((c-a)*(c-a)+(d-b)*(d-b));
    long double cx=(a-c)/l;
    long double sx=(b-d)/l;
    long double pi=acos(-1);
    pi*=2;
    pi/=n;
    long double x=l/2*(cx*cos(pi)-sx*sin(pi));
    long double y=l/2*(sx*cos(pi)+cx*sin(pi));
    cout<<fixed<<setprecision(15)<<x+m1<<" "<<y+m2<<endl;
    return 0;
}

#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; debug_print(__VA_ARGS__); } while(false)
template<typename T, typename... Ts> void debug_print(const T &t, const Ts &...ts) { cerr << t; ((cerr << ", " << ts), ...); cerr << endl; }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
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; }
template<typename T, typename... Ts> void print(const T& t, const Ts&... ts) { cout << t; ((cout << ' ' << ts), ...); cout << '\n'; }
template<typename... Ts> void input(Ts&... ts) { (cin >> ... >> ts); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

#include <iomanip>
#include <cmath>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const double pi = acos(-1);
    int n;
    input(n);
    double x1, y1, x2, y2;
    input(x1, y1, x2, y2);
    double xm = (x1 + x2) / 2, ym = (y1 + y2) / 2;
    double arg = 360.0 / n * pi / 180;
    x1 -= xm;
    y1 -= ym;
    cout << fixed << setprecision(15) << x1 * cos(arg) - y1 * sin(arg) + xm << " " << x1 * sin(arg) + y1 * cos(arg) + ym << endl;
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<int,int> pi;
typedef vector<pi> pii;
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
#define pb push_back
#define mk make_pair
#define en '\n'

void solve() {
	ll n,ans = 0;
	cin >> n;

	n *= 2;
	set<ll> factor;
	for (ll i = 1; i*i <= n; ++i)
	{
		// n^2 <= 2n so there will be 2 factors
		if(n%i == 0){
			factor.insert(i);
			//factor.insert(n/i);
		}
	}
	for(auto x:factor){
		if((n/x+1-x) % 2 == 0) ans++;
	}
	cout << ans*2 << en;
}

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

	/*freopen(".in","r",stdin);
	freopen(".out","w",stdout);*/

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

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
ll a,b,c,d=0,e=0,i,f=0,g=0,j,k=0,l=0,r,z,m[101],h[101],p[101],mod=1000000007,mod1=998244353;
string t,x,q,s;
ll df[201];
//double ;
vector<ll>v;
vector<ll>u,w;
vector<ll>dv[201];
//vector<string>;
set<string>y;
pair<ll,ll>n[17];
void dfs(ll x){
    for(ll i=0;i<dv[x].size();i++){
        if(df[dv[x][i]]==0){
            df[dv[x][i]]=df[x];
            dfs(dv[x][i]);
        }
    }
}
ll fastPow(ll a,ll b){
    ll d=1;
    while(b>0){
        if(b%2==1){
            d=d*a%mod;
        }
        b/=2;
        a=a*a%mod;
    }
    return d;
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>a;
    for(i=1;i<=sqrt(a);i++){
        if(i*i==a){
            v.pb(i);
            continue;
        }
        if(a%i==0){
            v.pb(i);
            v.pb(a/i);
        }
    }
    d=0;
    for(i=0;i<v.size();i++){
        if(v[i]%2==1){
            d+=2;
        }
    }
    cout<<d;
}


#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 998244353LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL;
const ll llMIN=-9223372036854775808LL;

//union find
struct UnionFind {
  vi col;
  map<ll, ll> nums;//[チーム番号]=そのチームに属する数
  UnionFind (ll n) {
    col.resize(n);
    for(ll i=0;i<n;i++)
      col[i]=i;
  }

  //ll root(ll x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  ll douf(ll pid){
    if (col[pid]==pid){
      return pid;
    }else{
      col[pid]=douf(col[pid]);
      return col[pid];
    }
  }

  void merge(ll a, ll b) {
    if ( douf(a)>douf(b) )swap(a,b);
    col[douf(b)]=douf(a);
  }

  void finish(){
    for(ll i=0;i<col.size();i++){
      col[i]=douf(i);
      nums[col[i]]++;
    }
  }
};

ll n,k;
int main() {
  int ans=0;
  cin>>n>>k;
  UnionFind uf(n);
  UnionFind uf2(n);
  vvi a(n, vi(n));
  REP(i,n)REP(j,n)cin>>a[i][j];

  for(ll i=0;i<n;i++){
    for(ll ii=0;ii<i;ii++){
      bool flag=true;
      for(ll j=0;j<n;j++){
        if (a[i][j]+a[ii][j]>k)flag=false;
      }
      if (flag==true){
        uf.merge(i,ii);
      }
    }
  }

  for(ll i=0;i<n;i++){
    for(ll ii=0;ii<i;ii++){
      bool flag=true;
      for(ll j=0;j<n;j++){
        if (a[j][i]+a[j][ii]>k)flag=false;
      }
      if (flag==true){
        uf2.merge(i,ii);
      }
    }
  }

  uf.finish();
  uf2.finish();
  ans=1;
  for(auto it:uf.nums){
    for(ll j=1;j<=it.second;j++)
      ans=ans*j%MOD;
  }
  for(auto it:uf2.nums){
    for(ll j=1;j<=it.second;j++)
      ans=ans*j%MOD;
  }

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

#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 998244353;
const ll N = 3e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, m;
vi adj[N];
int f[N], vis[N];

void input()
{
	cin >> n;
	FOR (i, 1, n) cin >> f[i];
	FOR (i, 1, n)
	{
		//int x, y;
		//cin >> x >> y;
		adj[i].pb(f[i]);
		adj[f[i]].pb(i);
	}
}

void dfs (int cur = 1)
{
    vis[cur] = 1;
	for (int i: adj[cur])
		if (!vis[i])
			dfs(i);
}

int power (int a, int b = mod - 2)
{
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

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

	int cnt = 0;
	FOR (i, 1, n)
	    if (!vis[i])
	        dfs(i), cnt++;

    int ans = (power(2, cnt) - 1 + mod) % mod;
    print(ans);
}


/**
 *  created: 21/03/2021, 13:00:59
**/

#include <bits/stdc++.h>

using namespace std;

template<bool inv, typename T>
void xor_convolution(int n, T a[]) {
    if (n == 0) {
        return;
    }
    for (int i = 0; i < n / 2; ++i) {
        T x = a[i] + a[i + n / 2], y = a[i] - a[i + n / 2];
        a[i] = x;
        a[i + n / 2] = y;
        if (inv) {
            a[i] /= 2;
            a[i + n / 2] /= 2;
        }
    }
    xor_convolution<inv>(n / 2, a);
    xor_convolution<inv>(n / 2, a + n / 2);
}

char buf[33];

string read() {
    scanf("%s", buf);
    return buf;
}

const int max_x = 1 << 20;

int n, m;
long long cnt[max_x];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) {
        string s = read();
        int x = 0;
        for (int j = 0; j < m; ++j) {
            x = x * 2 + s[j] - '0';
        }
        ++cnt[x];
    }
    xor_convolution<false>(1 << m, cnt);
    for (int i = 0; i < (1 << m); ++i) {
        cnt[i] *= cnt[i];
    }
    xor_convolution<true>(1 << m, cnt);
    long long ans = 0;
    for (int i = 0; i < (1 << m); ++i) {
        if (__builtin_popcount(i) % 2) {
            ans += cnt[i];
        }
    }
    assert(ans % 2 == 0);
    printf("%lld\n", ans / 2);
    return 0;
}

#include <iostream>
using namespace std;

int main() {
  long n,m,k,cou;
  cin>>n>>m;
  k=0;
  string str;
  for(long i=0; i<n; i++){
    cin>>str;
    cou=0;
    for(long j=0; j<m; j++){
      if(str.at(j)=='1'){
        cou++;
      }
    }
    cou=cou%2;
    if(cou==1)k++;
  }
  k=k*(n-k);
  cout<<k;
}


#include <iostream>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define fast_io                                                                                \
    ios::sync_with_stdio(false);                                                                                \
    cin.tie(0)
using ll = long long;

#define rep(i,a,n) for(ll i=a;i<=n;i++)
#define per(i,a,n) for(ll i=n;i>=a;i--)
#define pb push_back
#define mod 998244353
#define inf 0x3f3f3f3f
using namespace std;

//struct cmp {
//	bool operator()(pair<ll, ll>& p1, pair<ll, ll>& p2) {
//	}
//};
void solve() {
	double a, b, w;
	cin >> a >>b>> w;
	w *= 1000;
	double cmp = w / b;
	int min, max;
	if (cmp != (int)cmp) cmp++;
	min = (int)cmp;
	max = w / a;
	if (max < min) cout << "UNSATISFIABLE" << endl;
	else  cout << min << " " << max << endl;

	//string ans= "No";
	//if (h % m == 0) ans = "Yes";
	//cout << ans << endl;
}

int main(void)
{
	//int t; cin >> t; for (int i = 0; i < t; i++) {solve();}
	solve();
	return 0;
}

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<sstream>
#include<queue>
#include<list>
#include<stack>
#include<bitset>
#include<iomanip>
#include<set>
#include<cmath>
#include<map>
#include<functional>
#define int long long
#define IO ios::sync_with_stdio(false)
using namespace std;
int a,b,c;
const int mod=998244353;
signed main()
{
	IO;
	cin>>a>>b>>c;
	int a1,a2,a3;
	a1=(a*(a+1)/2)%mod;
	a2=(b*(b+1)/2)%mod;
	a3=(c*(c+1)/2)%mod;
	cout<<((((a1*a2)%mod)*a3)%mod);
 }


#include<bits/stdc++.h>
using namespace std;
typedef long long ll; typedef double db;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vl;
typedef vector<pii> vpii; typedef vector<pll> vpll;
#define FOR(n) for(int i=0;i<n;++i)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll gcd(ll a, ll b) { return a % b ? gcd(b, a % b) : b; }
const ll mod = 1e9 + 7; const ll inf = 0x3f3f3f3f;
ll qpow(ll a, ll b) { ll t = 1; while (b != 0) { if (b & 1)t = (t * a) % mod; a = (a * a) % mod; b >>= 1; }return t; }
int n, x;
string s;
signed main() {
	cin >> n >> x;
	cin >> s;
	for (auto& ch : s) {
		if (ch == 'o')++x;
		else {
			if (x)--x;
		}
	}
	cout << x << endl;
	return 0;
}

//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

int main(void){
	fio();
	cin>>n>>k>>s;
	for(auto go:s){
		//~ cout<<go<<endl;
		if(go=='o')k++;
		if(go=='x' && k!=0)k--;
	}
	cout<<k<<endl;
	return 0;
}


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

int main() {
  int A, B, ca, cb, ans, cur;
  cin >> A >> B;
  if(A>=B){
    ans=0;
    for(int i=1;i<=A;i++){
      cout << i << " ";
      if(i>B){ans+=i;}
    }
    for(int i=1;i<=B;i++){
      cur=-i;
      if(i==B){cur-=ans;}
      cout << cur << " ";
    }
  }else{
    ans=0;
    for(int i=1;i<=B;i++){
      cout << -i << " ";
      if(i>A){ans+=i;}
    }
    for(int i=1;i<=A;i++){
      cur=i;
      if(i==A){cur+=ans;}
      cout << cur << " ";
    }
  }
}

#ifdef DBG_MACRO_NO_WARNING
#include <dbg.h>
#else
#define dbg(...) ((void)0)
#endif
#include <bits/stdc++.h>
#define all(c) begin(c), end(c)
#define isz(c) (int)(c).size()

using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main(void)
{
    ios::sync_with_stdio(false), cin.tie(NULL);
    int n, m;
    cin >> n >> m;

    int one_parity_cnt[2] = {0, 0};
    for (int i = 0; i < n; ++i)
    {
        int    one_cnt = 0;
        string s;
        cin >> s;
        for (int j = 0; j < m; ++j)
            one_cnt += s[j] == '1';
        one_parity_cnt[one_cnt % 2]++;
    }
    cout << ll(one_parity_cnt[0]) * one_parity_cnt[1] << endl;
    return 0;
}


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

int main(){

    int n;
    cin >> n;
    vector<int>x(n);
    vector<long double>x2(n);
    for(int i=0;i<n;i++)cin >> x.at(i);
    for(int i=0;i<n;i++)x2.at(i)= x.at(i);
    long long ans1=0;
    for(int i=0;i<n;i++)ans1+=abs(x.at(i));
    cout << ans1 << endl;

    long double ans2=0;
    for(int i=0;i<n;i++)ans2+=abs(x2.at(i))*abs(x2.at(i));
    cout << fixed << setprecision(14)<< sqrt(ans2) << endl;

    int ans3=0;
    for(int i=0;i<n;i++)ans3=max(ans3,abs(x.at(i)));
    cout << ans3 << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define alfa "abcdefghijklmnopqrstuvwxyz"
#define pi 3.141592653589793
int main(void){
   // using t = tuple<int,int,int>;
    using p = pair<int,int>;
    int n;cin >> n;
    vector<int> a (n);
    vector<int> b (n);
    vector<int> c (n);
    for (int &i : a)cin >> i;
    for (int &i : b)cin >> i;
    for (int &i : c)cin >> i;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        v[i]=b[c[i]-1];
    }
    vector<ll> aa (n);
    vector<ll> bb (n);
    for (int i = 0; i < n; i++) {
        aa[a[i]-1]++;
        bb[v[i]-1]++;
    }
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        sum += aa[i] * bb[i];
    }
    cout << sum << endl;
    }


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define pb emplace_back
#define lb(v,k) (lower_bound(all(v),(k))-v.begin())
#define ub(v,k) (upper_bound(all(v),(k))-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define all(a) a.begin(),a.end()
#define rsort(a) {sort(all(a));reverse(all(a));}
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void outset(T s){auto itr=s.begin();while(itr!=s.end()){if(itr!=s.begin())cout<<' ';cout<<*itr;itr++;}cout<<'\n';}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll n;cin>>n;
    vvi v(3);
    rep(i,n*2){
        ll a;char c;cin>>a>>c;
        if(c=='R')v[0].pb(a);
        if(c=='G')v[1].pb(a);
        if(c=='B')v[2].pb(a);
    }
    rep(i,3)sort(all(v[i]));
    vi tmp;
    rep(i,3)if(v[i].size()%2)tmp.pb(i);
    if(tmp.size()==0)dame(0);
    ll ans=inf;
    vi t=v[tmp[1]];
    for(ll x:v[tmp[0]]){
        ll l=lb(t,x);
        if(l!=t.size())chmin(ans,t[l]-x);
        if(l)chmin(ans,x-t[l-1]);
    }
    ll a=tmp[0],b=tmp[1],c=3-a-b;
    if(v[c].size()){
        vp d,e;
        rep(i,v[c].size()){
            ll mi=inf;
            ll l=lb(v[a],v[c][i]);
            if(l!=v[a].size())chmin(mi,v[a][l]-v[c][i]);
            if(l)chmin(mi,v[c][i]-v[a][l-1]);
            d.pb(mi,i);
            mi=inf;l=lb(v[b],v[c][i]);
            if(l!=v[b].size())chmin(mi,v[b][l]-v[c][i]);
            if(l)chmin(mi,v[c][i]-v[b][l-1]);
            e.pb(mi,i);
        }
        sort(all(d));sort(all(e));
        if(d[0].se!=e[0].se)chmin(ans,d[0].fi+e[0].fi);
        else{
            chmin(ans,d[1].fi+e[0].fi);
            chmin(ans,d[0].fi+e[1].fi);
        }
    }
    out(ans);
}

#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define _2n (n << 1)
typedef long long ll;

vector<ll> R, G, B;

ll find(vector<ll>& a, vector<ll>& b, vector<ll>& another)
{
    ll mn = 0x3f3f3f3f3f3f3f3f;
    for (ll x : a) {
        auto it = lower_bound(b.begin(), b.end(), x);
        if (it != b.end())
            mn = min(mn, abs(*it - x));
        if (it != b.begin())
            mn = min(mn, abs(*(--it) - x));
    }
    ll mn1, mn2;
    mn1 = mn2 = 0x3f3f3f3f3f3f3f3f;
    for (ll x : a) {
        auto it = lower_bound(another.begin(), another.end(), x);
        if (it != another.end())
            mn1 = min(mn1, abs(*it - x));
        if (it != another.begin())
            mn1 = min(mn1, abs(*(--it) - x));
    }
    for (ll x : b) {
        auto it = lower_bound(another.begin(), another.end(), x);
        if (it != another.end())
            mn2 = min(mn2, abs(*it - x));
        if (it != another.begin())
            mn2 = min(mn2, abs(*(--it) - x));
    }
    return min(mn, mn1 + mn2);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    int n, i;
    ll a;
    char c;
    cin >> n;
    for (i = 0; i < _2n; i++) {
        cin >> a >> c;
        if (c == 'R')
            R.push_back(a);
        else if (c == 'G')
            G.push_back(a);
        else
            B.push_back(a);
    }
    sort(R.begin(), R.end());
    sort(G.begin(), G.end());
    sort(B.begin(), B.end());
    if (R.size() % 2 == 0 && G.size() % 2 == 0 && B.size() % 2 == 0)
        cout << 0 << endl;
    else if (R.size() % 2 == 0)
        cout << find(G, B, R) << endl;
    else if (G.size() % 2 == 0)
        cout << find(R, B, G) << endl;
    else
        cout << find(R, G, B) << endl;
    return 0;
}


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

typedef long L;
typedef long long LL;

const int MAXN = 1e5+10;

bool D[MAXN]={true}, O[MAXN]={true};

int main() {
    int N;
    cin >> N;
    int s = 0;
    for(int i=1; i<=N; i++) {
        int d =  i/10;
        if(i%10==7) {
            D[i] = false;
        } else {
            if(d) {
                if(D[d]==false) {
                    D[i] = false;
                } else {
                    D[i] = true;
                }
            } else {
                D[i] = true;
            }
        }
        int o =  i/8;
        if(i%8==7) {
            O[i] = false;
        } else {
            if(o) {
                if(O[o]==false) {
                    O[i] = false;
                } else {
                    O[i] = true;
                }
            } else {
                O[i] = true;
            }
        }
        if(D[i]==false||O[i]==false) {
            s++;
        }
    }
    cout << N-s << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
#define int long long

ostream& operator << (ostream& stream, const vector<int>& v) {
  for(int x : v) {
    stream << x << " ";
  }
  return stream;
}

//ostream& operator << (ostream& stream, const int *a) {
  //for(int i = 0; i < n; i++) {
    //stream << *(a + i) <<  " ";
  //}
  //return stream;
//}

int ncr(int n, int r) {
  if(r==0 || r==n) {
    return 1;
  }
  int ans = ncr(n-1, r-1);
  ans *= n;
  return ans/r;
}

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

  int l;
  cin >> l;
  //(l-1)C11
  cout << ncr(l-1, 11LL) << '\n';
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ps push_back
#define mk make_pair
#define ll long long int

const int dig=1e5+7;

void solve()
{
   vector<int> a(3);
   cin>>a[0]>>a[1]>>a[2];
   sort(a.begin(),a.end());
   cout<<a[1]+a[2]<<endl;

}

int main()
{
    ios_base::sync_with_stdio(false);
cin.tie(NULL);
     int t=1;
     //cin>>t;
     while(t--)
     {
    solve();
      }
     return 0;
    }

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ull unsigned long long int
#define pb push_back
#define mod 1000000007
#define PI 3.1415926535897932384626433832795
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define um unordered_map
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define double long double
#define fast_fast_kardo_ji ios_base::sync_with_stdio(false); cin.tie(NULL);

/////////Quick Functions start////////////////////////////////
bool comp(pair<int,int> a, pair<int,int> b){
	if(a.ss==b.ss)return a.ff<b.ff;
	return a.ss<b.ss;
}
struct myComp {
    constexpr bool operator()(pair<int, pii> const& a,pair<int, pii> const& b)
        const noexcept
    {
    	if(a.ff==b.ff)return a.ss.ff>b.ss.ff;
        return a.ff < b.ff;
    }
};

int gcd(int a, int b){
	if (b == 0) return a;
	return gcd(b, a % b);
}

int power(int a,int n){
	int res=1;
	while(n>0){
		if(n%2!=0){res*=a;n-=1;res%=mod;}
		else{a*=a;n/=2; a%=mod;}
	}
	return res;
}

bool isPrime(int n){
	// 6k+i (i=-1,0,1,2,3....)
	if (n <= 1)return false;
	if (n <= 3)return true;
	if (n%2 == 0 || n%3 == 0) return false;
	for (int i=5; i*i<=n; i=i+6) {
		if (n%i == 0 || n%(i+2) == 0)
			{return false;}
	}
	return true;
}

int primeFactors(int n){
	int count=0;
	while (n % 2 == 0){count+=1;n = n/2;}
	for (int i = 3; i <= sqrt(n); i = i + 2){
		while (n % i == 0){
			count+=1;
			n = n/i;
		}
	}
	if (n > 2){count+=1;}
	return count;
}

map<int,bool> printDivisors(int n){
	map<int,bool> mp;
	for (int i=1; i<=sqrt(n); i++){
		if(n%i == 0){
		if(n/i == i) mp[i]=true;
		else {mp[(i)]=true;mp[(n/i)]=true;}
		}
	}
	return mp;
}

void create_sparse_table(int n,vector<int> &v){
	// k=log2(n) -> n=size of the input array (for as large as 10^7, k is at max 25)
	int k=(int)log2(n*1.0);
	vector<vector<int>> st(n+1, vector<int> (k+1,0));
	for (int i = 0; i < n; i++)st[i][0] = v[i];
	for (int j = 1; j <= k; j++){
		for (int i = 0; i + (1 << j) <= n; i++)
			st[i][j] = min(st[i][j-1], st[i + (1 << (j - 1))][j - 1]);
	}
	//To make queries
	// int range = log2(R - L + 1);
	// int minimum = min(st[L][range], st[R - (1 << range) + 1][range]);
	return;
}

// vector<int> fact(200002,1);
// void preNCR(){
// 	for(int i=2;i<200002;i++){
// 		fact[i]=(fact[i-1]*i)%mod;
// 	}
// 	return;
// }

// int ncr(int n,int r){
// 	//call preNCR at start in main
// 	if(r>n){return 0;}
// 	int res=fact[n];
// 	// cout<<r<<endl;
// 	res*=(power(fact[r],mod-2)%mod);res%=mod;
// 	res*=(power(fact[n-r],mod-2)%mod);res%=mod;
// 	return res;
// }

void yes(){cout<<"YES"<<endl;}
void no(){cout<<"NO"<<endl;}
void alice(){cout<<"Alice"<<endl;}
void bob(){cout<<"Bob"<<endl;}
// vector<int> parent(200001,0);

// int amortize(int x){
// 	if(parent[x]==x)return x;
// 	parent[x]=amortize(parent[x]);
// 	return parent[x];
// }
// void combine(int x,int y){
// 	int parent1=amortize(x), parent2=amortize(y);
// 	parent[parent2]=parent1;
// }

//////////////Quick Functions End/////////////////////////////
/******* a+b=(a^b) + 2∗(a&b) *******/

void helper(int n){

	return;
}

signed main(){
	/////////////
	#ifndef ONLINE_JUDGE
	freopen("inputf.in","r",stdin);
	freopen("outputf.in","w",stdout);
	#endif
	/////////////
	fast_fast_kardo_ji
	/////////////
	// preNCR();
	// int t;
	// cin>>t;
	// while(t--){
		int a,b,c;cin>>a>>b>>c;
		cout<<max({a+b,b+c,a+c})<<endl;
		// vector<int> v(n,0);
		// for(int i=0;i<n;i++)cin>>v[i];
		// string s;cin>>s;
		// helper(n);
		// if(ans){cout<<"YES"<<endl;}
		// else{cout<<"NO"<<endl;}
	// }
	return 0;
}


#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int m = ri();
	int t = ri();
	int last_time = 0;
	int cur = n;
	bool res = true;
	for (int i = 0; i <= m; i++) {
		int a = i < m ? ri() : t;
		int b = i < m ? ri() : t;
		cur -= a - last_time;
		if (cur <= 0) res = false;
		cur = std::min(n, cur + b - a);
		last_time = b;
	}
	puts(res ? "Yes" : "No");
	return 0;
}

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

int main() {
  int N, S, D;
  cin >> N >> S >> D;

  string check = "No";
  int X, Y;

  for(int i=0; i<N; i++){

    cin >> X >> Y;

    if(S > X && Y > D){
      check = "Yes";
      break;
    }
  }

  cout << check;
}


#include<bits/stdc++.h>
#define N 400001
using namespace std;
int n,a[N],b[N],p[N],fp[N],vis[N],tot;
vector<int>v;
struct Node{int x,y;}ans[N];
signed main(void){
	int i,x,mi,pos;scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",a+i);
	for(i=1;i<=n;++i)scanf("%d",b+i);
	for(i=1;i<=n;++i){scanf("%d",p+i),fp[p[i]]=i,vis[i]=(p[i]==i)?1:0;if(p[i]^i&&b[p[i]]>=a[i])return puts("-1"),0;}
	for(i=1;i<=n;++i)if(!vis[i]){
		mi=b[p[i]],pos=i;v.clear();v.push_back(i);
		vis[x=i]=1;while(p[x]^i){vis[x=p[x]]=1,v.push_back(x);if(b[p[x]]<mi)mi=b[p[x]],pos=x;}
		for(int x:v)if(a[x]<=mi&&x^pos&&x^p[pos])return puts("-1"),0;
		for(x=pos;fp[x]^pos;x=fp[x])ans[++tot]={x,fp[x]};
	}for(printf("%d\n",tot),i=1;i<=tot;++i)printf("%d %d\n",ans[i].x,ans[i].y);
	return 0;
}

#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int main() {
    int N;
    scanf("%d", &N);
    vector<int> A(N), B(N), P(N);
    for (int i = 0; i < N; i++)
        scanf("%d", &A[i]);
    for (int i = 0; i < N; i++)
        scanf("%d", &B[i]);
    for (int i = 0; i < N; i++) {
        scanf("%d", &P[i]);
        P[i]--;
    }
    vector<bool> visit(N);
    vector<pii> ans;
    for (int i = 0; i < N; i++) {
        if (visit[i]) continue;
        int cur = i;
        vector<int> qu;
        int mxA = -1;
        while (!visit[cur]) {
            visit[cur] = 1;
            qu.push_back(cur);
            if (mxA == -1 || A[cur] > A[mxA])
                mxA = cur;
            cur = P[cur];
        }
        if (qu.size() == 1) continue;
        for (int j: qu)
            if (A[j] <= B[P[j]])
                return !printf("-1\n");
        cur = P[mxA];
        while (cur != mxA) {
            ans.push_back({cur, mxA});
            cur = P[cur];
        }
    }
    printf("%d\n", (int)ans.size());
    for (auto [a, b] : ans)
        printf("%d %d\n", a + 1, b + 1);
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a),i##end=(b);i<i##end;i++)
#define REP(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define RFOR(i,a,b) for(int i=(a),i##end=(b);i>i##end;i--)
#define RREP(i,a,b) for(int i=(a),i##end=(b);i>=i##end;i--)
typedef long long LL;

const int maxs=(1<<16)+1;
const int maxn=9;
int dp[maxn][maxs],h,w,a,b,S;
inline int lowbit(const int& ans) {
	FOR(w,0,32) if(!(ans&(1<<w))) return w;
}
inline int right(const int& u,const int& st) {
	if(u%w==w-1) return -1;
	if(st&(1 << u+1)) return -1;
	return st|(1 << u+1)|(1<<u);
}
inline int down(const int& u,const int& st) {
	if(u+w>=S) return -1;
	if(st&(1 << u+w)) return -1;
	return st|(1 << u+w)|(1<<u);
}

int main() {
	memset(dp,0,sizeof(dp));
	scanf("%d%d%d%d",&h,&w,&a,&b);
	dp[a][0]=1;
	S=h*w;
	FOR(st,0,1<<S) REP(i,0,a) {
		int& ans=dp[i][st];
		if(!ans) continue;
		//printf("i=%d st=%d\n",i,st);
		int u=lowbit(st);
		if(u>=S) continue;
		dp[i][st|(1<<u)]+=ans;
		if(!i) continue;
		int r=right(u,st),d=down(u,st);
		if(r>=0) dp[i-1][r]+=ans;
		if(d>=0) dp[i-1][d]+=ans;
	}
	printf("%d\n",dp[0][(1<<S)-1]);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
using LL=long long;
using P=pair<int,int>;
using T=tuple<int,int,int>;
constexpr int mod=998244353;
constexpr LL inf=1e9;
constexpr double eps=1e-13;
constexpr double pi=3.141592653589;
int in(){
    int x;
    scanf("%d",&x);
    return x;
}
struct graph{
    vector<vector<vector<int>>>e;
    vector<vector<int>>dist;
    graph(int n){
        e.resize(n,vector<vector<int>>(26));
        dist.assign(n,vector<int>(n,inf));
    }
    void add_edge(int v,int u,int c){
        e[v][c].emplace_back(u);
        e[u][c].emplace_back(v);
    }
    void bfs(int s1,int s2){
        dist[s1][s2]=0;
        queue<P>q;
        q.push({s1,s2});
        while(q.size()){
            auto [v1,v2]=q.front();
            q.pop();
            for(int i=0;i<26;i++){
                for(int j=0;j<e[v1][i].size();j++){
                    for(int k=0;k<e[v2][i].size();k++){
                        int u1=e[v1][i][j],u2=e[v2][i][k];
                        if(dist[v1][v2]+1<dist[u1][u2]){
                            dist[u1][u2]=dist[v1][v2]+1;
                            q.push({u1,u2});
                        }
                    }
                }
            }
        }
    }
};
int main(){
    int n=in(),m=in();
    graph g(n);
    int a[m],b[m];
    for(int i=0;i<m;i++){
        a[i]=in()-1,b[i]=in()-1;
        char c;
        cin>>c;
        g.add_edge(a[i],b[i],c-'a');
    }
    g.bfs(0,n-1);
    int ans=inf;
    for(int i=0;i<n;i++)ans=min(ans,g.dist[i][i]*2);
    for(int i=0;i<m;i++)ans=min(ans,min(g.dist[a[i]][b[i]],g.dist[b[i]][a[i]])*2+1);
    cout<<(ans<inf ? ans : -1)<<endl;
    return 0;
}