#include <algorithm>
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll A, ll B, ll C, ll D) {
  cout <<   min(A,B) + min(C,D) << endl;
}

int main() {
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  ll C;
  cin >> C;
  ll D;
  cin >> D;
  solve(A, B, C, D);
  return 0;
}

#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

struct Jinfo{
	int start;
	int len;
};

int main(){
	string str;
	while(cin >> str){
		int res = 0;

		deque<char> jdeq;
		deque<char> odeq;
		deque<char> ideq;

		int onum=0;
		for(int i=0;i<str.size();i++){
			if(str[i]=='J'){
				if(odeq.size() > 0
					|| ideq.size() > 0){
						odeq.clear();
						ideq.clear();
						jdeq.clear();
				}

				jdeq.push_back(str[i]);
			}

			else if(str[i]=='O'){
				if(ideq.size() > 0){
					jdeq.clear();
					odeq.clear();
					ideq.clear();
				}
				odeq.push_back(str[i]);
			}

			else if(str[i]=='I'){
				ideq.push_back(str[i]);
			}

			if(ideq.size() > 0
				&& odeq.size() > 0
				&& jdeq.size() > 0
				&& jdeq.size() >= odeq.size()
				&& ideq.size() >= odeq.size()){
					res = max(res,(int)odeq.size());
					jdeq.clear();
					ideq.clear();
					odeq.clear();
			}

		}

		printf("%d\n",res);
	}
}


#include <bits/stdc++.h>

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

ll m[100][100];

void show_table(ll I, ll J) {
  for (ll i = 0; i <= I; i++) {
    for (ll j = 0; j <= J; j++) {
      cout << m[i][j] << " ";
    }
    cout << "" << endl;
  }
  cout << "" << endl;
}

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll H, W;
  scanf("%lld %lld", &H, &W);

  for (ll y = 0; y < H; y++) {
    for (ll x = 0; x < W; x++) {
      m[y][x] = -1;
    }
  }

  ll spaces = 0;

  for (ll y = 0; y < H; y++) {
    string s;
    cin >> s;

    for (ll x = 0; x < W; x++) {
      if (s[x] == '.') {
        m[y][x] = INF;
        spaces++;
      }
    }
  }

  queue<pll> q;
  q.push(make_pair(0, 0));
  m[0][0] = 0;

  for (;;) {
    if (q.empty()) {
      break;
    }
    auto pos = q.front();
    ll y = pos.first;
    ll x = pos.second;

    ll c = m[y][x];

    if (y >= 1 && m[y - 1][x] > c + 1) {
      m[y - 1][x] = c + 1;
      q.push(make_pair(y - 1, x));
    }
    if (y < H - 1 && m[y + 1][x] > c + 1) {
      m[y + 1][x] = c + 1;
      q.push(make_pair(y + 1, x));
    }
    if (x >= 1 && m[y][x - 1] > c + 1) {
      m[y][x - 1] = c + 1;
      q.push(make_pair(y, x - 1));
    }
    if (x < W - 1 && m[y][x + 1] > c + 1) {
      m[y][x + 1] = c + 1;
      q.push(make_pair(y, x + 1));
    }

    q.pop();
  }

  // show_table(3, 3);

  ll a = m[H - 1][W - 1];

  if (a == INF) {
    cout << -1 << endl;
    return 0;
  }
  // cout << "a:" << a << endl;

  ll ans = spaces - a - 1;

  cout << ans << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll h,w; cin>>h>>w;
    char s[h][w];
    rep(i,h)rep(j,w) cin>>s[i][j];

    ll di[]={1,0,-1,0},dj[]={0,1,0,-1};
    bool ok=true;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='.') continue;
            bool ok2=false;
            rep(k,4){
                ll ni=i+di[k],nj=j+dj[k];
                if(ni<0||h<=ni||nj<0||w<=nj) continue;
                if(s[i][j]=='#' && s[ni][nj]=='#') ok2=true;
            }
            if(!ok2){
                ok=false;
                break;
            }
        }
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main()
{
	string a,b;
	cin>>a>>b;
	int dp[1001][1001]={};
	for(int i=0;i<=a.length();i++)dp[i][0]=i;
	for(int j=0;j<=b.length();j++)dp[0][j]=j;
	for(int i=0;i<a.length();i++)
	{
		for(int j=0;j<b.length();j++)
		{
			dp[i+1][j+1]=min(dp[i][j]+(a[i]!=b[j]),min(dp[i+1][j]+1,dp[i][j+1]+1));
		}
	}
	cout<<dp[a.length()][b.length()]<<endl;
	return 0;
}

#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vvi = vector<vector<int>> ;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI 3.141592653
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
  int n; cin >> n;
  string s; cin >> s;
  bool fin;
  if(s[0] == 'o'){fin = true;}
  else{fin = false;}
  bool ans = true;

  vector<char> s1(n+1);
  s1[0] = 'W'; s1[1] = 'S';
  vector<char> s2(n+1);
  s2[0] = 'W'; s2[1] = 'W';
  vector<char> s3(n+1);
  s3[0] = 'S'; s3[1] = 'S';
  vector<char> s4(n+1);
  s4[0] = 'S'; s4[1] = 'W';

  while(true){
  bool f;
  for(int i = 2; i <= n; i++){
    f = true;
    if(s1[i-2] == 'W'){f = !f;}
    if(s1[i-1] == 'W'){f = !f;}
    if(s[i-1] == 'x'){f = !f;}
    if(f){s1[i] = 'S';}
    else{s1[i] = 'W';}
  }
  if(fin){if(s1[n-1] == 'W' && s1[0] == s1[n])  {rep(i, n){cout << s1[i];}ans = false; break;}}
  else{if(s1[n-1] == 'S' && s1[0] == s1[n])  {rep(i, n){cout << s1[i];}ans = false; break;}}
  for(int i = 2; i <= n; i++){
    f = true;
    if(s2[i-2] == 'W'){f = !f;}
    if(s2[i-1] == 'W'){f = !f;}
    if(s[i-1] == 'x'){f = !f;}
    if(f){s2[i] = 'S';}
    else{s2[i] = 'W';}
  }
  if(fin){if(s2[n-1] == 'S' && s2[0] == s2[n] ) {rep(i, n){cout << s2[i];}ans = false; break;}}
  else{if(s2[n-1] == 'W' && s2[0] == s2[n])  {rep(i, n){cout << s2[i];}ans = false; break;}}

  for(int i = 2; i <= n; i++){
    f = true;
    if(s3[i-2] == 'W'){f = !f;}
    if(s3[i-1] == 'W'){f = !f;}
    if(s[i-1] == 'x'){f = !f;}
    if(f){s3[i] = 'S';}
    else{s3[i] = 'W';}
  }
  if(fin){if(s3[n-1] == 'S' && s3[0] == s3[n]) {rep(i, n){cout << s3[i];} ans = false; break;}}
  else{if(s3[n-1] == 'W' && s3[0] == s3[n])  {rep(i, n){cout << s3[i];}ans = false;  break;}}

  for(int i = 2; i <= n; i++){
    f = true;
    if(s4[i-2] == 'W'){f = !f;}
    if(s4[i-1] == 'W'){f = !f;}
    if(s[i-1] == 'x'){f = !f;}
    if(f){s4[i] = 'S';}
    else{s4[i] = 'W';}
  }
  if(fin){if(s4[n-1] == 'W'  && s4[0] == s4[n])  {rep(i, n){cout << s4[i];} ans = false;break;}}
  else{if(s4[n-1] == 'S' && s4[0] == s4[n]) { rep(i, n){cout << s4[i];}ans = false; break;}}

  cout << -1;
  break;
  }
  cout << endl;
}


#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000007
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;

int main()
{
int n;cin>>n;
int ans =0;

int i = 0;
while(i*i<=n)
{
    i++;
}
cout<<(i-1)*(i-1)<<endl;
 return 0;
}

#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

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

        ll ans = 1;
        rep(i, 1, N+1) {
                if (i * i > N) break;
                ans = i;
        }
        cout << ans*ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,x;
    cin>>a>>b;
    c=max(a+b,a-b);
    x=max(c,a*b);
    cout<<x<<endl;

    return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, n) for (int i = 1; i <= (int)(n); i++)
#define fore(i, a) for (auto &i:a)
#define ll long long
#define pll vector<pair<ll, ll>>
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)

using namespace std;

const long double PI = acos(-1);

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}

bool isInteger(double x){return floor(x) == x;}

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

	int a,b,c,d;cin >> a >> b >> c >> d;

	cout << min(a,b)+min(c,d) << endl;
}


#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	int n;
	cin >> n;
	vector<long long int> v;
	for (int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		v.push_back(a);
	}
	int max = 0;
	long long int ans = 0;
	for (int i = 0; i < v.size(); i++) {
		if (v[i] < max) {
			ans = ans + max - v[i];
		}
		else if (v[i] > max) {
			max = v[i];
		}
	}
	cout << ans;
}

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

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

int main() {
	ll N;
	cin >> N;
	ll A, high = 0, ans = 0;

	REP (i, N) {
		cin >> A;
		high = max(A, high);
		ans += high - A;
	}

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


 #include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;
 using namespace __gnu_pbds;
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          998244353
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -1e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

 typedef tree<pii, null_type, less<pii>, rb_tree_tag,
            tree_order_statistics_node_update>  odst;

void pr_init()
{

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

    #endif
}

pair<int,pii> proc (string s)
{
  int an = 0 , lef = 0 , rg = 0;;

  for(int i=0;i<sz(s);i++)
  {
    if(s[i]=='(') an--;
    else an++;
    lef = max(lef,an);
  }

  an = 0;
  for(int i=sz(s)-1;i>=0;i--)
  {
    if(s[i]=='(')an++;
    else an--;
    rg = max(rg,an);
  }

  return {lef,{rg,an}};

}

int arr[1000001],vis[1000001];
void solve()
{

 int n;

 cin >> n;

 vector<pair<int,pii> >  sq;

 vpi lef,rg;
 for(int i=0;i<n;i++)
 {
   string s;
   cin >> s;
   pair<int,pii> rm = proc(s);
   //cout<<rm.fi<<" "<<rm.se.fi<<" "<<rm.se.se<<endl;
   lef.pb({rm.fi,i});
   rg.pb({rm.se.fi,i});
   arr[i] = rm.se.se;
 }

 sort(lef.begin(),lef.end());
 sort(rg.begin(),rg.end());

 int i = 0,j=0,fw=0,bk=0,fl=0;

 while(i<sz(lef) && j<sz(rg))
 {
    if(vis[lef[i].se]) i++;
    else if(vis[rg[j].se]) j++;
    else
    {
      if(fw - lef[i].fi < 0 || bk + rg[j].fi > 0) fl=1;
      fw += arr[lef[i].se];
      vis[lef[i].se] =1;
      i++;
      if(!vis[rg[j].se]) bk += arr[rg[j].se] , vis[rg[j].se]=1;
      j++;
    }
 }

 if(fl || (fw+bk)!=0)
 {
   cout<<"No\n";
 }
 else  cout<<"Yes\n";

}

int32_t main()
{
 pr_init();
  fastio;

  auto start = high_resolution_clock::now();

  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start);

    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl;

 }

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 9e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

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

    int n;
    cin >> n;
    vector<pair<int, int> > s1, s2;

    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        for(auto it = s.find("()"); it != string::npos; it = s.find("()")) {
            s.erase(it, 2);
        }

        int l = count(all(s), ')');
        int r = count(all(s), '(');

        if (r - l >= 0) {
            s1.push_back(make_pair(l, r));
        }
        else {
            s2.push_back(make_pair(l, r));
        }
    }

    sort(all(s1), [](const auto& l, const auto& r){
        return l.fi < r.fi;
    });
    sort(all(s2), [](const auto& l, const auto& r){
        return l.se > r.se;
    });

    int l = 0, r = 0;
    for (auto s: s1) {
        l = l + s.fi - min(s.fi, r);
        r = r - min(s.fi, r) + s.se;
    }
    for (auto s: s2) {
        l = l + s.fi - min(s.fi, r);
        r = r - min(s.fi, r) + s.se;
    }

    if (l == 0 && r == 0) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}


#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 2020;
typedef long long ll;
const int mod = 998244353;
 inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
 }
 inline ll inverse(int x){ return pow(x, mod - 2); }
int h, w;
char ch[maxn][maxn];
int right[maxn][maxn];
int down[maxn][maxn];
int can[maxn][maxn];

inline int calc(int * a) {
	auto min = [&](int x,int y){ return a[x] < a[y] ? x : y; };
	static int st[20][maxn];
	int ret = 0;
	for(int i = 1;i < h;++i) st[0][i] = i;
	for(int i = 1;i < 13;++i) for(int j = 1;j + (1 << i) - 1 < h;++j) {
		st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << i - 1)]);
	}
	std::function<void(int, int)> solve = [&](int l,int r) {
		if(l > r) return ;
		const int lg = std::__lg(r - l + 1);
		int mn = min(st[lg][l], st[lg][r - (1 << lg) + 1]);
		ret = std::max(ret, (a[mn] + 1) * (r - l + 2));
		solve(l, mn - 1), solve(mn + 1, r);
	};
	solve(1, h - 1);
	return ret;
}
int main() {
	  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> h >> w;
	rep(i, 1, h) cin >> ch[i] + 1;
	for(int i = h - 1;i >= 1;--i) {
		for(int j = w - 1;j >= 1;--j) {
			can[i][j] = !(ch[i][j] + ch[i + 1][j] + ch[i][j + 1] + ch[i + 1][j + 1] & 1);
			right[j][i] = can[i][j] ? right[j + 1][i] + 1 : 0;
		}
	}
	int ans = w;
	rep(i, 1, w - 1) ans = std::max(ans, calc(right[i]));
	cout << ans << '\n';
}

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

int main(){
	int h,w; cin >> h >> w;
	vs s(h); rep(i,h) cin >> s[i];
	vl dist(h+1,-1);
	int ans = w;
	rep(j,w){
		vector<pii> st;
		st.emplace_back(0,0);
		REP(i,1,h+1){
			if(i < h){
				if(j==0 || dist[i] == 1){
					int d = 0;
					bool rev = s[i][j] != s[i-1][j];
					REP(k,j,w){
						if(rev == (s[i][k] != s[i-1][k])) d++;
						else break;
					}
					dist[i] = d;
				}else{
					dist[i]--;
				}
			}else{
				dist[i] = 0;
			}
			if(st.empty() || st.back().first < dist[i]){
				st.emplace_back(dist[i],i);
			}else{
				int pos = i;
				while(!st.empty()){
					if(st.back().first >= dist[i]){
						pii p = st.back();
						chmax(ans, p.first*(i-p.second)+p.first);
						pos = p.second;
						st.pop_back();
					}else{
						st.emplace_back(dist[i], pos);
						break;
					}
				}
			}
		}
	}
	cout << ans << "\n";
}


#include <bits/stdc++.h>
#include <set>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 998244353;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou(bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<vector<int>> children;
  vector<int> hukasa;
  vector<int> kazu;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    kazu = vector<int>(n,1);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
      kazu.at(rx) += kazu.at(ry);
    }
    else{
      par.at(rx) = ry;
      kazu.at(ry) += kazu.at(rx);
    }
  }
  void newkazu(){
    int n = kazu.size();
    for(int i=0;i<n;i++){
      kazu.at(i) = kazu.at(root(i));
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> s(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)cin >> s.at(i).at(j);
  }
  vector<vector<int>> table(h,vector<int>(w,-1));
  queue<pii> q;
  q.push(pii(0,0));
  table.at(0).at(0) = 1;
  bool flag = false;
  int count;
  while(!q.empty()){
    pii tmppair = q.front();
    q.pop();
    int x,y;
    tie(x,y) = tmppair;
    set<pii> se;
    if(x-1 >= 0)se.insert(pii(x-1,y));
    if(x+1 < h)se.insert(pii(x+1,y));
    if(y-1 >= 0)se.insert(pii(x,y-1));
    if(y+1 < w)se.insert(pii(x,y+1));
    for(auto t:se){
      int tx,ty;
      tie(tx,ty) = t;
      if(s.at(tx).at(ty) == '.' && table.at(tx).at(ty) == -1){
        table.at(tx).at(ty) = table.at(x).at(y) + 1;
        q.push(t);
      }
      if(t == pii(h-1,w-1)){
        count = table.at(tx).at(ty);
        flag = true;
        break;
      }
    }
    if(flag) break;
  }
  if(!flag) cout << -1 << endl;
  else{
    int count2 = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(s.at(i).at(j) == '#')count2++;
      }
    }
    cout << h * w - count - count2 << endl;
  }
}

#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";};
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    matrix dxdy={{1,0},{-1,0},{0,1},{0,-1}};
    ll h,w;
    cin >> h >> w;
    vector<vector<char>> s(h,vector<char>(w));
    ll ctr=0;
    rp(i,h){
        rp(j,w){
            cin >> s[i][j];
            if(s[i][j]=='#') ctr++;
        }
    }
    queue<pair<P,ll>> que;
    que.push(mp(mp(0,0),0));
    matrix seen(h,Vi(w,0));
    ll shortest=-1;
    while(!que.empty()){
        P loc=que.front().first;
        ll dist=que.front().second;
        que.pop();
        if(seen[loc.first][loc.second]==1) continue;
        if(loc.first==h-1&&loc.second==w-1) {
            shortest=dist;
            break;
        }
        seen[loc.first][loc.second]=1;
        for(auto vec:dxdy){
            if(loc.first+vec[0]<0||loc.first+vec[0]>=h||loc.second+vec[1]<0||loc.second+vec[1]>=w) continue;
            if(s[loc.first+vec[0]][loc.second+vec[1]]=='.'){
                que.push(mp(mp(loc.first+vec[0],loc.second+vec[1]),dist+1));
            }
        }
    }
    if(shortest==-1){
        print(-1);
    }else{
        print(h*w-ctr-shortest-1);
    }

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


#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
  int N;
  cin >> N;
  N *= 2;
  int L[N];
  for (int i = 0; i < N; i++) cin >> L[i];

  int count = 0;

  priority_queue<int> Que;
  for (int i = 0; i < N; i++){
    Que.push(L[i]);
  }

  while(!Que.empty()){
    Que.pop();
    if (Que.empty()) break;
    count += Que.top();
    Que.pop();
  }

  cout << count << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> l(2*n);
  int sum =0;
  rep(i,2*n){
    cin >> l[i];
  }
  rep(i,2*n){
    rep(j,2*n-i-1){
      int temp;
      if(l[j]>l[j+1]){
        temp =l[j];
        l[j] = l[j+1];
        l[j+1]=temp;
      }
    }
  }
  rep(i,n){
    sum +=l[2*i];
  }
  cout << sum << endl;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAX 100001
#define MOD 1000000007
#define ll long long
#define ld long double
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main() {
	fast;
	ll n;
	cin >> n;
	vector<ll> v(n);
	ll sum = 0;
	for(ll i=0;i<n;i++) {
		cin >> v[i];
		sum += v[i];
	}
	sum -= v[0];
	ll ans = 0;
	for(ll i=0;i<n-1;i++) {
		ans = (ans + ((sum % MOD) * (v[i] % MOD)) % MOD) % MOD;
		sum -= v[i + 1];
	}
	cout << ans << endl;
}

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
long long grid[600000] = {};
vector<long long> finding_X[2000000];
long long zero[600000] = {};
long long cnt_zero(long long l, long long r) {
	long long ans = zero[r];
	if (l != 0) {
		ans -= zero[l - 1];
	}
	return ans;
}
pair<long long,long long> calc(long long X) {
	pair<long long, long long> ans = make_pair(1, 0);
	if (finding_X[X].size() != 0) {
		ans.second = 1;
	}
	for (int i = 1; i < finding_X[X].size(); ++i) {
		long long zero_move = cnt_zero(finding_X[X][i - 1], finding_X[X][i]);
		ans.first += zero_move * ans.second;
		ans.first %= MAX_MOD;
		ans.second += ans.first;
		ans.second %= MAX_MOD;
	}
	return ans;
}
int main() {
	iostream::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	REP(i, n) {
		cin >> grid[i + 1];
		grid[i + 1] ^= grid[i];
	}
	for (int i = 1; i <= n; ++i) {
		zero[i] = zero[i - 1];
		if (grid[i] == 0) {
			zero[i]++;
		}
		else {
			finding_X[grid[i]].push_back(i);
		}
	}
	if (grid[n] != 0) {
		cout << calc(grid[n]).first << endl;
		return 0;
	}
	long long ans = 1;
	for (int i = 0; i < zero[n]-1; ++i) {
		ans *= 2;
		ans %= MAX_MOD;
	}
	for (int i = 1; i < (1 << 20); ++i) {
		ans += calc(i).second;
		ans %= MAX_MOD;
	}
	cout << ans << endl;
}


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

// 1個置くと3増えて全体でN*Q
// クオリティQは3の倍数になる必要がある(N != 0 mod 3)

using block = vector<string>;
// Quality 1
block b3 = {
        "a..",
        "a..",
        ".aa"
};
// Quality 3
block b4 = {
        "aacd",
        "bbcd",
        "cdaa",
        "cdbb"
};
// Quality 3
block b5 = {
        "aabbc",
        "bc..c",
        "bc..d",
        "c.ccd",
        "cddee"
};
// Quality 3
block b7 = {
        "ac..c..",
        "ac..c..",
        "b.cc.cc",
        "bc..c..",
        "ac..c..",
        "a.cc.cc",
        ".aabbaa"
};

void horizontal_add(block &a, block b){
    for (int i = 0; i < a.size(); ++i) a[i] += b[i];
}

void vertical_add(block &a, block b){
    a.insert(a.end(), b.begin(), b.end());
}

block solve_k(int n, block b){
    block res = b;
    for (int i = 0; i < n - 1; ++i) {
        horizontal_add(res, b);
    }
    block unit = res;
    for (int i = 0; i < n - 1; ++i) {
        vertical_add(res, unit);
    }
    return res;
}

block solve(int n){
    block res;
    if (n % 3 == 0) return solve_k(n/3, b3);
    if (n % 4 == 0) return solve_k(n/4, b4);
    int t = __builtin_ctz(n);
    int m = n >> t; // m >= 5 が保証される
    if ((m - 1) % 4) res = b7;
    else res = b5;
    for (int i = 0; i < (m - 5) / 4; ++i) {
        horizontal_add(res, block(res.size(), "...."));
        string s(res.size(), '.');
        block below(4, s);
        horizontal_add(below, b4);
        vertical_add(res, below);
    }
    return solve_k(n/m, res);
}

int main() {
    int N;
    cin >> N;
    if (N == 2) {
        cout << -1 << "\n";
    } else {
        auto ans = solve(N);
        for (int i = 0; i < N; ++i) {
            cout << ans[i] << "\n";
        }
    }
    return 0;
}

#include <cstdio>

const char pat3[3][4]={"a..",
		       "a..",
		       ".aa"};
const char pat4[4][5]={"aacd",
		       "bbcd",
		       "cdaa",
		       "cdbb"};
const char pat5[5][6]={"..def",
		       "..def",
		       "aaggh",
		       "bbj.h",
		       "ccjii"};
const char pat6[6][7]={"aacd..",
		       "bbcd..",
		       "..aacd",
		       "..bbcd",
		       "cd..aa",
		       "cd..bb"};
const char pat7[7][8]={"abc....",
		       "abc....",
		       "def....",
		       "def....",
		       "m..gghh",
		       "m..iijj",
		       ".nnkkll"};

char grid[1005][1005];

int main(){
  int N;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      grid[i][j]='.';
    }
  }
  if(N==2){
    printf("-1\n");
  }else if(N==3){
    for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      printf("%c",pat3[i][j]);
    }
    printf("\n");
    }
  }else{
    int index=0;
    while(N-index>7){
      for(int i=0;i<4;i++){
	for(int j=0;j<4;j++){
	  grid[index+i][index+j]=pat4[i][j];
	}
      }
      index+=4;
    }
    if(N-index==4){
      for(int i=0;i<4;i++){
	for(int j=0;j<4;j++){
	  grid[index+i][index+j]=pat4[i][j];
	}
      }
    }else if(N-index==5){
      for(int i=0;i<5;i++){
	for(int j=0;j<5;j++){
	  grid[index+i][index+j]=pat5[i][j];
	}
      }
    }else if(N-index==6){
      for(int i=0;i<6;i++){
	for(int j=0;j<6;j++){
	  grid[index+i][index+j]=pat6[i][j];
	}
      }
    }else if(N-index==7){
      for(int i=0;i<7;i++){
	for(int j=0;j<7;j++){
	  grid[index+i][index+j]=pat7[i][j];
	}
      }
    }
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
	putchar(grid[i][j]);
      }
      printf("\n");
    }
  }
}


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	string a;
	cin >> a;
	reverse(a.begin(),a.end());
	cout << a << endl;
}

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

int main()
{
    string s;
    cin >> s;
    bool ok = false;
    rep(i, s.size() - 1) {
        if(s[i] == 'A' && s[i + 1] == 'C') ok = true;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,j,n) for(int i = j; i < n; i++)

int main(){

	while(1){

		vector< vector<int> > map (21, vector<int>(21,0));
		vector< vector<int> > map2 (21, vector<int>(21,0));

		int px = 10, py = 10;

		int N;
		cin >> N;

		if(N == 0){
			break;
		}

		vector<int> tx(N);
		vector<int> ty(N);

		rep(i,N){
			cin >> tx[i];
			cin >> ty[i];
			map2[ty[i]][tx[i]] = 1;
		}

		int M;
		cin >> M;

		string str;
		int v;

		rep(i,M){
			cin >> str >> v;

			if(str == "N"){
				for(int i = py; i <= py + v; i++){
					map[i][px] = 1;
				}
				py += v;
			}
			else if(str == "E"){
				for(int i = px; i <= px + v; i++){
					map[py][i] = 1;
				}
				px += v;
			}
			else if(str == "S"){
				for(int i = py; i >= py - v; i--){
					map[i][px] = 1;
				}
				py -= v;
			}
			else if(str == "W"){
				for(int i = px; i >= px - v; i--){
					map[py][i] = 1;
				}
				px -= v;
			}
			  // rep(i,21){
			  // 	rep(j,21){
			  // 		cout << map[i][j] << " ";
			  // 	}
			  // 	cout << endl;
			  // }
			  // cout << endl;
		}

		int sum = 0;

		rep(i,21){
			rep(j,21){
				if(map[i][j] == 0 && map2[i][j] == 1){
					sum++;
				}
			}
		}

		if(sum == 0){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" <<endl;
		}

	}
	return 0;
}

#include <stdio.h>

typedef struct _Gem{
	int x;
	int y;
	bool hit;
} Gem;

static void
pick_gem(Gem* g, int n, int x, int y)
{
	for (int i = 0; i < n; i++) {
		if (!g[i].hit && g[i].x == x && g[i].y == y) {
			g[i].hit = true;
			return;
		}
	}
}

static bool
check_gem(Gem* g, int n)
{
	for (int i = 0; i < n; i++) {
		if (g[i].hit == false) {
			return false;
		}
	}

	return true;
}

int
main(void)
{

	char line[80];
	int n;
	int m;

	Gem g[20];

	char d[30];
	int l[30];

	while (true) {
		if (fgets(line, sizeof line, stdin) == NULL) {
			return 1;
		}
		if (sscanf(line, "%d", &n) != 1) {
			return 1;
		}

		if (n == 0) {
			break;
		}

		for (int i = 0; i < n; i++) {
			if (fgets(line, sizeof line, stdin) == NULL) {
				return 1;
			}
			if (sscanf(line, "%d %d", &(g[i].x), &(g[i].y)) != 2) {
				return 1;
			}
			g[i].hit = false;
		}

		if (fgets(line, sizeof line, stdin) == NULL) {
			return 1;
		}
		if (sscanf(line, "%d", &m) != 1) {
			return 1;
		}

		for (int i = 0; i < m; i++) {
			if (fgets(line, sizeof line, stdin) == NULL) {
				return 1;
			}
			if (sscanf(line, "%c %d", &(d[i]), &(l[i])) != 2) {
				return 1;
			}
		}

		int x = 10;
		int y = 10;
		for (int i = 0; i < m; i++) {
			if (d[i] == 'N') {
				for (int k = 1; k <= l[i]; k++) {
					pick_gem(g, n, x, ++y);
				}
			} else if (d[i] == 'S') {
				for (int k = 1; k <= l[i]; k++) {
					pick_gem(g, n, x, --y);
				}
			} else if (d[i] == 'E') {
				for (int k = 1; k <= l[i]; k++) {
					pick_gem(g, n, ++x, y);
				}
			} else {
				for (int k = 1; k <= l[i]; k++) {
					pick_gem(g, n, --x, y);
				}
			}
		}
		printf("%s\n", (check_gem(g, n) ? "Yes" : "No"));
	}

	return 0;
}


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

map<long long int,long long int>m;
map<long long int,long long int>::iterator it,it1;
main()
{
    long long int n,i,j,k,cnt=0,ans=1;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=n-1;i>0;i--)
    {
        if(a[i]==a[i-1])
        {
            cnt++;
            ans*=a[i];
            i--;
        }
        if(cnt==2)
        {
            break;
        }
    }
    if(cnt==2)
    {
        cout<<ans<<endl;
    }
    else{
        cout<<0<<endl;
    }
}

#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
/// check for test case before submitting
void vfun()
{
    ll n,k;
    cin>>n;
    vector <ll> v(n);
    fo(i,n)
    cin>>v[i];

}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("inputh.txt", "r", stdin);
    freopen("outputh.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
    //cin>>test;
    while(test--)
    {

            set <ll> s;
            vector  <ll> v;
            ll x;
            ll n;
            cin>>n;
            fo(i,n)
            {
                cin>>x;
                if(s.count(x))
                    {v.pb(x);s.erase(x);}
                else
                    s.insert(x);
            }
            ll ans=0;
            sort(v.begin(),v.end());
            if(v.size()>=2)
            {
                ll n=v.size();
                ans=v[n-1]*v[n-2];
            }
            cout<<ans;

//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not


#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

const int maxn=105;
int n,a[maxn],m,b[maxn];

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

inline bool cmp(int a,int b){
	return a%2 > b%2;
}

int main(){
	n=rd(); m=rd();
	go(i,m+1,1) a[i]=rd();
	sort(a+1,a+m+1,cmp);
	int t=0;
	while(a[t+1]%2 == 1) t++;
	if(t > 2){ printf("Impossible"); return 0; }
	if(t == 2) swap(a[m],a[2]);
	go(i,m+1,1) printf("%d ",a[i]); puts("");
	go(i,m+1,1) b[i]=a[i];
	if(m == 1) m++;
	b[1]--; b[m]++;
	if(b[1] == 0){
		printf("%d\n",m-1);
		go(i,m+1,2) printf("%d ",b[i]);
	}else{
		printf("%d\n",m);
		go(i,m+1,1) printf("%d ",b[i]);
	}
	return 0;
}//Faze


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

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll n;

int main(){
    cin >> n;
    cout << n / 3 << endl;
}

#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n;
  cin >> n;
  ll a=0;
  while(3*a<=n){
    a++;
  }
  cout << a-1 << endl;

}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> s(H, vector<char>(W));
  int memo = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> s.at(i).at(j);
      if (s.at(i).at(j) == '.') {
        memo++;
      }
    }
  }
  vector<vector<int>> M(H, vector<int>(W, 0));
  queue<int> X;
  queue<int> Y;
  X.push(0);
  Y.push(0);
  vector<int> vx = {1, -1, 0, 0}, vy = {0, 0, 1, -1};
  s.at(0).at(0) = '#';
  while (X.size() > 0) {
    for (int i = 0; i < 4; i++) {
      if ((X.front() + vx.at(i)) >= 0 && (Y.front() + vy.at(i)) >= 0
          && (X.front() + vx.at(i)) < H && (Y.front() + vy.at(i)) < W
          && s.at(X.front() + vx.at(i)).at(Y.front() + vy.at(i)) == '.'
          && M.at(X.front() + vx.at(i)).at(Y.front() + vy.at(i)) == 0) {
            X.push(X.front() + vx.at(i));
            Y.push(Y.front() + vy.at(i));
            M.at(X.front() + vx.at(i)).at(Y.front() + vy.at(i)) = M.at(X.front()).at(Y.front()) + 1;
      }
    }
    X.pop();
    Y.pop();
  }
  if (M.at(H - 1).at(W - 1) != 0) {
    cout << memo - (M.at(H - 1).at(W - 1) + 1) << endl;
  }
  else {
    cout << -1 << endl;
  }
}

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

const int INF=1001001001;
int dy[4]={-1,0,1,0};
int dx[4]={0,-1,0,1};

int main(){
    int h,w;
    cin>>h>>w;
    int ans=0;
    vector<string>s(h);
    rep(i,h)cin>>s[i];
    rep(i,h)rep(j,w)if(s[i][j]=='.')ans++;
    vector<vector<int>>dist(h,vector<int>(w,INF));
    queue<P>q;
    q.push(P(0,0));
    dist[0][0]=1;
    while(!q.empty()){
        int y=q.front().first;
        int x=q.front().second;
        q.pop();
        rep(dir,4){
            int vy=y+dy[dir];
            int vx=x+dx[dir];
            if(vy<0||vy>=h||vx<0||vx>=w)continue;
            if(s[vy][vx]=='#'||dist[vy][vx]!=INF)continue;
            dist[vy][vx]=dist[y][x]+1;
            q.push(P(vy,vx));
        }
    }
    ans-=dist[h-1][w-1];
    if(dist[h-1][w-1]!=INF)cout<<ans<<endl;
    else cout<<-1<<endl;
}


#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
#define MAX 100000
vector<vector<int>>edge(MAX);
bool visited[MAX];
int prenum[MAX],parent[MAX],lowest[MAX],timer;
int N;
void dfs(int current,int prev){
    prenum[current]=lowest[current]=timer;
    timer++;
    visited[current]=true;
    int  next;
    for(int i=0;i<edge[current].size();i++){
        next=edge[current][i];
        if(!visited[next]){
            parent[next]=current;
            dfs(next,current);
            lowest[current]=min(lowest[current],lowest[next]);
        }else if(next != prev){
            lowest[current] = min(lowest[current],prenum[next]);
        }
    }
}
void art_point(){
    timer=1;
    dfs(0,-1);
    map<int,int>Mp;
    int np=0;
    for(int i=1;i<N;i++){
        int p=parent[i];
        if(p==0)np++;
        else if(prenum[p]<=lowest[i])Mp[p]++;
        if(np>1)Mp[0]++;
    }
        for(auto itr:Mp)
            cout<<itr.first<<endl;

}
signed main(){
    int m;
    cin>>N>>m;
    edge.resize(N);
    rep(i,N)visited[i]=false;
    for(int i=0;i<m;i++){
        int s,t;
        cin>>s>>t;
        edge[s].push_back(t);
        edge[t].push_back(s);
    }
    art_point();
}

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
int main(){
    int n;
    cin>>n;
    vpii red(n),blue(n);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        red[i]=mp(a,b);
    }
    rep(i,n){
        int c,d;
        cin>>c>>d;
        blue[i]=mp(d,c);
    }
    sort(all(red));
    reverse(all(red));
    sort(all(blue));
    rep(i,n){
        int c,d;
        tie(d,c)=blue[i];
        blue[i]=mp(c,d);
    }
    vbo tmp(n,true);
    int ans=0;
    rep(i,n){
        rep(j,n){
            if(red[i].first<blue[j].first&&red[i].second<blue[j].second&&tmp[j]){
                ans++;
                tmp[j]=false;
                break;
            }
        }
    }
    cout<<ans<<endl;
}


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

class tsort {
public:
  int V;
  vector<vector<int>> G;
  vector<int> deg, res;
  tsort(int node_size) : V(node_size), G(V), deg(V, 0) {}
  void add(int from, int to) {
    G.at(from).push_back(to);
    deg.at(to)++;
  }
  bool solve() {
    queue<int> que;
    for(int i = 0; i < V; i++) {
      if(deg.at(i) == 0) {
        que.push(i);
      }
    }
    while(!que.empty()) {
      int p = que.front();
      que.pop();
      res.push_back(p);
      for(int v : G.at(p)) {
        if(--deg.at(v) == 0) {
          que.push(v);
        }
      }
    }
    return (*max_element(deg.begin(),deg.end()) == 0);
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  tsort T(N);
  for (int i = 0; i < N - 1 + M; i++) {
    int a, b;
    cin >> a >> b;
    G.at(--b).push_back(--a);
    T.add(a, b);
  }
  T.solve();
  vector<int> V(N);
  int cnt = 0;
  for (auto r : T.res) V.at(r) = cnt++;
  for (int i = 0; i < N; i++) {
    int sz = G.at(i).size();
    if (!sz) cout << 0 << "\n";
    else if (sz == 1) cout << G.at(i).at(0) + 1 << "\n";
    else {
      int mx = 0;
      for (auto g : G.at(i)) mx = max(mx, V.at(g));
      for (auto g : G.at(i)) {
        if (V.at(g) == mx) {
          cout << g + 1 << "\n";
          break;
        }
      }
    }
  }
}

//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

using Graph=vector<vector<int>>;
// グラフ、頂点の入次数、頂点数を受け取り、そのトポロジカルソートを記録した配列を返す関数
vector<int> topological_sort(Graph &G, vector<int> &indegree, int V) {
    // トポロジカルソートを記録する配列
    vector<int> sorted_vertices;

    // 入次数が0の頂点を発見したら、処理待ち頂点としてキューに追加する
    queue<int> que;
    for (int i = 0; i < V; i++) {
        if (indegree[i] == 0) {
            que.push(i);
        }
    }

    // キューが空になるまで、操作1~3を繰り返す
    while (que.empty() == false) {
        // キューの先頭の頂点を取り出す
        int v = que.front();
        que.pop();

        // その頂点と隣接している頂点の入次数を減らし、0になればキューに追加
        for (int i = 0; i < G[v].size(); i++) {
            int u = G[v][i];
            indegree[u] -= 1;
            if (indegree[u] == 0) que.push(u);
        }
        // 頂点vを配列の末尾に追加する
        sorted_vertices.push_back(v);
    }

    // トポロジカルソートを返す
    return sorted_vertices;
}

int main(){
    int N,M;
    cin>>N>>M;
    Graph G(N),oya(N);
    vector<int> indegree(N,0);

    REP(i,N-1+M){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        G[a].push_back(b);
        oya[b].push_back(a);
        indegree[b]++;
    }
    vector<int> topo=topological_sort(G,indegree,N);
    vector<int> ans(N);
    vector<int> rev(N+1);
    REP(i,N) rev[topo[i]]=i;
    rev[N]=-1;

    REP(i,N){
        if(oya[i].size()==0) ans[i]=0;
        else{
            int idx=N;
            REP(j,oya[i].size()){
                int v=oya[i][j];
                if(rev[v]>rev[idx]&&rev[v]<rev[i]){
                    idx=v;
                }
            }
            ans[i]=idx+1;
        }

    }
    REP(i,N) cout<<ans[i]<<endl;

}


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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

char s[1000001];

int main(){

  fgets(s, sizeof(s), stdin);
  int res = 0, oc, ic, jc;
  int i, j, k, l;
  int slen = strlen(s);
  jc = oc = ic = 0;
  rep(i, slen){
    if(ic == 0 && oc == 0 && s[i] == 'J') jc++;
    else if(jc && ic == 0 && s[i] == 'O') oc++;
    else if(jc && oc && s[i] == 'I') ic++;
    else{
      if(jc >= oc && ic >= oc) res = max(res, oc);
      jc = oc = ic = 0;
      if(s[i] == 'J') jc++;
    }
  }

  if(jc >= oc && ic >= oc) res = max(res, oc);
  printf("%d\n", res);
  return 0;
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
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 PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

map<int, bool> mp;
int cnt4;

int main() {
    int n;
    cin >> n;
    REP(i,n) {
        int j;
        cin >> j;
        mp[j] = true;
    }

    int m;
    cin >> m;
    REP(i,m) {
        int j;
        cin >> j;
        if (mp[j]) cnt4++;
    }

    cout << cnt4 << endl;

    return 0;
}


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

lli n;
string s, t;

int main(void){
	cin >> n >> s >> t;
	lli ans = 2*n;
	rep(i, n){
		if(s.substr(i, n-i) == t.substr(0, n-i)){
			ans = min(ans, n+i);
		}
	}
	cout << ans << endl;
	return 0;
}

#include<iostream>
using namespace std;

int main() {
	int D, T, S;
	cin >> D >> T >> S;
	int A = S * T;

	if (A >= D) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long

int main() {
	intt N; std::cin >> N;
	std::map<std::string, int> MAP;
	std::vector<std::string> s(N);
	for (auto& r : s) {
		std::cin >> r;
		++MAP[r];
	}
	intt M; std::cin >> M;
	std::vector<std::string> t(M);
	for (auto& r : t) {
		std::cin >> r;
		--MAP[r];
	}
	int max = -201;
	for (auto& r : MAP)
		max = std::max(max, r.second);

	std::cout << std::max(max, 0) << std::endl;
}

#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll n;
  cin >> n;
  string s;
  map<string, int> mps;
  for(int i = 0; i < n; ++i)
  {
    cin >> s;
    mps[s]++;
  }
  ll m;
  cin >> m;
  string t;
  map<string, int> mpt;
  for(int i = 0; i < m; ++i)
  {
    cin >> t;
    mpt[t]++;
  }

  int ans = 0;
  for(const auto& m : mps)
  {
    ans = max(ans, mps[m.first] - mpt[m.first]);
  }
  cout << ans;

}

int main()
{
  fastio;
  solve();

  return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>

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

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

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;
ll modadd(ll a,ll b,ll mod=MOD){
    return (a%mod+b%mod)%mod;
}

ll modsub(ll a,ll b,ll mod=MOD){
    a%=mod;
    b%=mod;
    if(a>=b) return a-b;
    else return mod-b+a;
}

ll modmul(ll a,ll b,ll mod=MOD){
    return ((a%mod)*(b%mod))%mod;
}

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

ll moddiv(ll a,ll b,ll mod=MOD) {
    return modmul(a, modpow(b, mod-2));
}

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

    ll n,m;
    cin>>n>>m;
    vll x(n),y(m);
    for(ll i=0;i<n;i++)cin>>x[i];
    for(ll j=0;j<m;j++)cin>>y[j];

    sort(ALL(x));sort(ALL(y));

    ll a=0;
    for(ll i=0;i<n;i++){
        a=modadd(a,modmul(x[i],i-(n-1-i)));
    }

    ll b=0;
    for(ll i=0;i<m;i++){
        b=modadd(b,modmul(y[i],i-(m-1-i)));
    }

    cout<<modmul(a,b)<<endl;

    return 0;
}

#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int n , m , a , b , pref1 , pref2;
int main() {
    abdelrahman010
    cin >> n >> m;
    for(int i = 0;i < n;i++) {
        int x;
        cin >> x;
        if(i)
            a = (a + ((1ll * x * i) % mod - pref1 + mod) % mod) % mod;
        pref1 = (pref1 + x) % mod;
    }
    int ans = 0;
    for(int i = 0;i < m;i++) {
        int x;
        cin >> x;
        b = ((1ll * x * i) % mod - pref2 + mod) % mod;
        ans = (ans + (1ll * a * b) % mod) % mod;
        pref2 = (pref2 + x) % mod;
    }
    cout << ans;
    return 0;
}


////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define cl clear()
#define sqr(a) (a*a)
#define mk make_pair
#define po pop()
#define pu push
#define pb push_back
#define pf push_front
#define pob pop_back()
#define pof pop_front()
string en="\n";
string sp=" ";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<long long>
#define vs  vector<string>
#define MX LLONG_MAX
#define MN LLONG_MIN
#define MOD 1000000007
#define vp(vi,x) cin>>x; vi.pb(x);
#define bsearch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
bool isprm(LL a){if(a==1)return false; for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL ceil2(LL a,LL b){LL c=a/b; if(a%b)c++; return c; }
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,p,q,a,b,c=0;
    bool f=0,ff=0;string st,s1,s2,s3; char ch;
    while(cin>>n)
    {
        c=0,a=MX;
        rep(i,n)
        {
            cin>>x;
            if(x<a)c++,a=x;
        }
        cout<<c<<en;
    }
    return 0;
}

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define SORT(v) sort(ALL(v))
//#define scanf scanf_s

int main()
{
	int n, p;
	while (cin >> n >> p, n)
	{
		int m[55] = {};
		int wan = p;
		int i, j;
		j = 0;
		for (i = 1; i < 1000005; i++)
		{
			if (wan>0)
			{
				wan--;
				m[j]++;
				if (m[j] == p)
				{
					cout << j << endl;
					break;
				}
			}
			else
			{
				wan += m[j];
				m[j] = 0;
			}

			j++;
			if (j >= n) j = 0;
		}
	}
	return 0;
}


#include <iostream>
using namespace std;
int main(){
  int t;
  while(cin>>t && t > 0){
    int p1 = 0, p2 = 0;
    while(t > 0){
      int a = 0, b = 0;
      cin >> a >> b;
      if(a < 0 || a > 9 || a < 0 || a > 9){
        continue;
      }
      if(a > b){
        p1 += a + b;
      }
      else if(a < b){
        p2 += a + b;
      }
      else{
        p1 += a;
        p2 += b;
      }
      t--;
    }
    cout << p1 << " " << p2 << endl;
  }
  return 0;
}

#include<cstdio>
#include<queue>

using namespace std;

int main()
{
	int ap, bp, turnnum, acard, bcard;
	ap = bp = 0;
	queue<int>adeck, bdeck;
	while (1)
	{
		scanf("%d", &turnnum);
		if (turnnum == 0)break;

		for (int i = 0; i < turnnum; i++)
		{
			scanf("%d %d", &acard, &bcard);
			adeck.push(acard);
			bdeck.push(bcard);
		}
		while (adeck.empty() == false)
		{
			if (adeck.front()>bdeck.front())
			{
				ap += adeck.front() + bdeck.front();
				adeck.pop();
				bdeck.pop();
			}
			else if(adeck.front() < bdeck.front())
			{
				bp += adeck.front() + bdeck.front();
				adeck.pop();
				bdeck.pop();
			}
			else
			{
				ap += adeck.front();
				bp += bdeck.front();
				adeck.pop();
				bdeck.pop();
			}
		}
		printf("%d %d\n", ap, bp);
                ap=0;bp=0;
	}

}


#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int q,n;
vl a;
string s;

int main(){
	cin>>q;
	while(q){
		cin>>n;
		a=vl(n);
		for(auto &i:a) cin>>i;
		cin>>s;
		reverse(a.begin(),a.end());
		reverse(s.begin(),s.end());
		vl b;
		bool B=0;
		for(int i=0;i<n;i++){
			ll x=a[i];
			for(auto j:b) x=min(x,x^j);
			if(s[i]=='0') b.push_back(x);
			else if(x) B=1;
		}
		cout<<B<<endl;
		q--;
	}
}

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

int solve () {
	int n;
	cin >> n;
	vector<long long> a(n);
	for (auto &e : a) cin >> e;
	string s;
	cin >> s;

	vector<long long> b;
	for (int i = n; i--> 0;) {
		long long e = a[i];
		for (const auto &c : b) e = min(e, e^c);
		if (e > 0) {
			if (s[i] == '1') return 1;
			b.push_back(e);
		}
	}
	return 0;
}

int main() {
	int t;
	cin >> t;
	while (t--) cout << solve() << '\n';
	return 0;
}


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

using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> l(m), r(m);
  rep(i, m) cin >> l[i] >> r[i];
  ll a = LLONG_MIN, b = LLONG_MAX;
  rep(i, m) updatemax(a, l[i]);
  rep(i, m) updatemin(b, r[i]);
  cout << max(0ll, b - a + 1) << endl;
}

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i=0; i < int(n); i++)

// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = -1;  // sizes[y]は無意味な値となるので-1を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

// 頂点a, bをつなぐコストcostの（無向）辺
struct Edge
{
  int a, b, cost;

  // コストの大小で順序定義
  bool operator<(const Edge& o) const {
    return cost < o.cost;
  }
};

// 頂点数と辺集合の組として定義したグラフ
struct Graph
{
  int n;  // 頂点数
  vector<Edge> es;  // 辺集合

  // クラスカル法で無向最小全域木のコストの和を計算する
  // グラフが非連結のときは最小全域森のコストの和となる
  int kruskal() {
    // コストが小さい順にソート
    sort(es.begin(), es.end());

    UnionFind uf(n);
    int min_cost = 0;

    rep(ei, es.size()) {
      Edge& e = es[ei];
      if (!uf.same(e.a, e.b)) {
        // 辺を追加しても閉路ができないなら、その辺を採用する
        min_cost += e.cost;
        uf.unite(e.a, e.b);
      }
    }

    return min_cost;
  }
};

// 標準入力からグラフを読み込む
Graph input_graph() {
  Graph g;
  int m;
  cin >> g.n >> m;
  rep(i, m) {
    Edge e;
    cin >> e.a >> e.b >> e.cost;
    g.es.push_back(e);
  }
  return g;
}

int main()
{
  Graph g = input_graph();
  cout << g.kruskal() << endl;
  return 0;
}


#include<iostream>
using namespace std;

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  cout << ((A<B ? A : B) + (C<D ? C : D)) << endl;
  return 0;
}

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a[5],b[5];
  int ans=0;
  cin>>a[0]>>a[1]>>b[0]>>b[1];
  sort(a,a+2);
  sort(b,b+2);
  ans=a[0]+b[0];
  cout<<ans<<"\n";

  return 0;
}


#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int X, Y;
    cin >> X >> Y;
    int ans = 0;
    switch(X) {
        case 1:
            ans += 300000;
            break;
        case 2:
            ans += 200000;
            break;
        case 3:
            ans += 100000;
            break;
    }
    switch(Y) {
        case 1:
            ans += 300000;
            break;
        case 2:
            ans += 200000;
            break;
        case 3:
            ans += 100000;
            break;
    }

    if (X == 1 && Y == 1) ans += 400000;
    cout << ans << endl;

    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    string S,T;

    cin>>S>>T;

    string r=T+S;

    cout<<r;

    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
const int N=1005;
int h,w,A,B;
int a[N][N];
int main()
{
	scanf("%d%d%d%d",&h,&w,&A,&B);
	for(int i=1;i<=B;i++)
		for(int j=1;j<=A;j++)
			a[i][j]=1;
	for(int i=B+1;i<=h;i++)
		for(int j=A+1;j<=w;j++)
			a[i][j]=1;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
			printf("%d",a[i][j]);
		printf("\n");
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

double dp[301][301][301];

double sushi(int n, int x, int y, int z){
	if(x==0 && y==0 && z==0){
		return 0;
	}

	if(x<0 || y<0 || z<0){
		return 0;
	}

	if(dp[x][y][z] > -0.9){
		return dp[x][y][z];
	}

	double res = n + x*sushi(n, x-1, y, z) + y*sushi(n, x+1, y-1, z) + z*sushi(n, x, y+1, z-1);
	return dp[x][y][z] = res/(x+y+z);
}

int main(){
	memset(dp, -1, sizeof(dp));

	int n;
	cin >> n;

	int a[n];
	int ones=0, twos=0, threes=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		switch(a[i]){
			case 1:
				ones++;
				break;
			case 2:
				twos++;
				break;
			case 3:
				threes++;
				break;
		}
	}

	cout << setprecision(10) << sushi(n, ones, twos, threes);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;
const int N = 301;
double dp[N][N][N];
// dp[x][y][z] = x 3s, y 2s, z 1s and (n - x - y - z) zeros
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1;
    //cin >> num_tests;
    while(num_tests-->0){
        int n; cin >> n;
        int cnt[4] = {0};
        FOR(i,0,n){
            int x; cin >> x;
            cnt[x]++;
        }
        dp[0][0][0] = 0.0;
        FOR(x,0,n+1){
            FOR(y,0,n+1){
                FOR(z,0,n+1){
                    int zeros = n - (x+y+z);
                    if(zeros == n) continue;
                    if(zeros < 0) continue;
                    double res = 1.0;
                    // if I pick 3
                    if(x > 0) res += (1.0 * x/n) * dp[x-1][y+1][z];
                    // if I pick 2
                    if(y > 0) res += (1.0 * y/n) * dp[x][y-1][z+1];
                    // if I pick 1
                    if(z > 0) res += (1.0 * z/n) * dp[x][y][z-1];
                    res = res/(1 - 1.0*zeros/n);
                    dp[x][y][z] = res;
                }
            }
        }
        cout << fixed << setprecision(10);
        cout << dp[cnt[3]][cnt[2]][cnt[1]];
    }
}


# include <iostream>
using namespace std;

int N;
int K;
int A[100005];
int maximum=0;
int factor;

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

    else
    {
        return gcd(b, a%b);
    }
}

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

    for (int i=1; i<=N; i++)
    {
        cin>>A[i];
        maximum=max(maximum, A[i]);
        if (i==1)
        {
            factor=A[i];
        }

        else
        {
            factor=gcd(factor, A[i]);
        }
    }

    if (K>maximum)
    {
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }

    if (K%factor!=0)
    {
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }

    cout<<"POSSIBLE"<<endl;
}

#include <iostream>
#include <map>
#include <cmath>

using namespace std;

#define L 998244353

int main(int argc, char* argv[]) {
  long long N;
  cin >> N;

  long long d[N];
  for (int i = 0; i < N; ++i)
    cin >> d[i];

  if (d[0] != 0) {
    cout << "0" << endl;
    return 0;
  }

  map<long long, long long> m;
  long long max_v = 0;
  for (int i = 0; i < N; ++i) {
    if (m.find(d[i]) == m.end())
      m[d[i]] = 0;
    ++m[d[i]];
    max_v = max(d[i], max_v);
  }

  if (m[0] > 1) {
    cout << 0 << endl;
    return 0;
  }

  long long ret = 1;
  for (long long i = 1; i <= max_v; ++i) {
    if (m.find(i) == m.end()) {
      cout << 0 << endl;
      return 0;
    }
    for (int j = 0; j < m[i]; ++j) {
      ret *= m[i - 1];
      ret %= 998244353;
    }
  }

  cout << ret << endl;

  return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n;
  cin >> n;
  while(n--) {
    string s;
    int out = 0;
    vector<int> rui(3);
    int ten = 0;
    while(out < 3) {
      // FOR(it,rui)
      //   cout << *it << " ";
      // cout << endl;
      cin >> s;
      if (s == "HIT") {
        if (rui[2]) ten++;
        rui[2] = rui[1];
        rui[1] = rui[0];
        rui[0] = 1;
      } else if (s == "HOMERUN") {
        REP(i,3) {
          ten += rui[i];
        }
        ten++;
        rui = vector<int>(3);
      } else
        out++;
    }
    cout << ten << endl;
  }
}

// #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define fastIO	cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c)	for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(), c_end=c.end(); it!=c_end; ++it)

// ------------------- include, typedef, define END. -------------------

int Hit(int *rui){
	rui[0]++;
	// 塁を進める
	FOR(i, 1, 4){
		if (rui[i - 1]==2){
			rui[i]++;
			rui[i - 1] = 1;
		}
	}
	if (rui[3]!=0){
		rui[3] = 0;
		return 1;
	}
	return 0;
}

int Homerun(int *rui){
	int ret = 1;
	FOR(i, 0, 4)
		if (rui[i])
			ret++;
	return ret;
}

int main(){
	fastIO;
	int n, outCount = 0, tokuten = 0;
	string in;
	// rui[0]〜rui[2] = 1塁〜3塁, rui[3] = 本塁
	// 各値はその塁にいる人数(0〜2)
	int rui[4] = {};
	cin >> n;
	while (cin >> in){
		if (in == "OUT")
			outCount++;
		if (outCount < 3){
			if (in == "HIT"){
				tokuten += Hit(rui);
			}
			else if (in == "HOMERUN"){
				tokuten += Homerun(rui);
				FOR(i, 0, 4)	rui[i] = 0;
			}
		}
		else{
			cout << tokuten << endl;
			FOR(i, 0, 4)	rui[i] = 0;
			tokuten = 0;
			outCount = 0;
		}
	}
	return 0;
}


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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
#define all(x) x.begin(), x.end()
#define rep(i,a,b) for(int i = a; i < b; i++)

int V, E;
vvi conn(100002);
vi vis(100002);
vb trail(100002);
vb cut(100002);

int dfs_min(int v, int depth, int parent) {
  if(vis[v] > 0) return vis[v];
  vis[v] = depth;
  trail[v] = true;

  int minHit = depth;
  rep(i,0,(int)conn[v].size()) {
    if(conn[v][i] != parent && (vis[conn[v][i]] == 0 || trail[conn[v][i]])) {
      int hit = dfs_min(conn[v][i], depth+1, v);
      minHit = min(minHit, hit);
      if(hit >= depth && conn[v].size() > 1)
	cut[v] = true;
    }
  }

  trail[v] = false;
  return minHit;
}

int main() {
  cin >> V;
  cin >> E;
  rep(e,0,E) {
    int s, t;
    cin >> s;
    cin >> t;
    conn[s].push_back(t);
    conn[t].push_back(s);
  }

  dfs_min(0, 1, -1);
  if(V > 1) {
    cut[0] = false;
    bool remember = cut[1];
    fill(all(vis), 0);
    dfs_min(1, 1, -1);
    cut[1] = remember;
  }

  rep(v,0,V)
    if(cut[v])
      cout << v << '\n';
}

#include <bits/stdc++.h>

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

int n;

int main() {
	read(n);
	print(180 * (n - 2));
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

#define N 100

void searchIndex(int mat[][N], int n, int obj, int *row, int *col);
void changeGroup(int group[], int n, int g_old, int g_new);

int main(void)
{
	int n;
	cin >> n;

	int group[N];
	for (int i = 0; i < n; i++) group[i] = i;

	int a[N][N];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int aij;
			cin >> aij;
			a[i][j] = aij;
		}
	}

	int e[N * N];
	int k = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			e[k++] = a[i][j];
		}
	}

	sort(e, e + k);

	int p = 0;
	while (e[p] == -1) p++;

	int cnt = 0;
	for (int q = p; q < k; q++) {
		int i, j;
		searchIndex(a, n, e[q], &i, &j);
		if (group[i] == group[j]) continue;
		cnt += e[q];
		if (group[i] > group[j]) changeGroup(group, n, group[i], group[j]);
		else changeGroup(group, n, group[j], group[i]);
	}

	cout << cnt << endl;

	return 0;
}

void searchIndex(int mat[][N], int n, int obj, int *row, int *col)
{
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (mat[i][j] == obj) {
				mat[i][j] = -1;
				*row = i;
				*col = j;
				return;
			}
		}
	}
}

void changeGroup(int group[], int n, int g_old, int g_new)
{
	for (int i = 0; i < n; i++) {
		if (group[i] == g_old) group[i] = g_new;
	}
}

#include <iostream>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>

using namespace std;

typedef long long signed int ll;

constexpr ll NIL = -20000000000;

int n,z[100][100];
set <int> t;

int main() {
    cin >> n;
    for(int i = 0;i < n;i++) {
        for(int j = 0;j < n;j++) {
            cin >> z[i][j];
            if(z[i][j] == -1) z[i][j] = 100000;
        }
    }
    int res = 0;
    t.insert(0);
    while(t.size() != n) {
        int me = 100000;int mi = -1;
        for(auto e:t) {
            for(int i = 0;i < n;i++) {
                if(me > z[e][i] && t.find(i) == t.end()) {
                    me = z[e][i];
                    mi = i;
                }
            }
        }
        res += me;
        t.insert(mi);
    }
    cout << res << endl;
}


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

int main(){
	string s;
	cin >> s;
	if(s == "SUN") cout << 7 << endl;
	if(s == "MON") cout << 6 << endl;
	if(s == "TUE") cout << 5 << endl;
	if(s == "WED") cout << 4 << endl;
	if(s == "THU") cout << 3 << endl;
	if(s == "FRI") cout << 2 << endl;
	if(s == "SAT") cout << 1 << endl;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int R;
    cin >> R;
    double c = 2*R*3.14159;
    cout << c;
}


#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define pw(x) (1<<(x))
#define inf 1000000005
#define MOD 1000000007
#define N 100005
#define M 1000003
#define LOG 19
#define KOK 250
#define EPS 0.0000001
using namespace std;

int n,x;
int s[N],dp[N],pt[N];
int res[205][205];

int mul(int x,int y) {

	return (ll)x*y%MOD;

}

int add(int x,int y) {

	x+=y;

	if(x>=MOD) x-=MOD;
	if(x<0) x+=MOD;

	return x;

}

int main() {

	scanf("%d %d",&n,&x);

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

	sort(s+1,s+1+n);

	for(int i=0;i<=n+1;i++) {

		res[i][0]=1;

		for(int j=1;j<=n+1;j++) {

			res[i][j]=mul(res[i][j-1],i+j-1);

		}

	}

	int ptr=0;

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

		while(s[ptr+1]<=i && ptr+1<=n) ++ptr;

		pt[i]=ptr;

		if(ptr==0) dp[i]=i;

		for(int j=ptr;j>=1;j--) {

			int nm=i%s[j];

			dp[i]=add(dp[i],mul(dp[nm],res[pt[nm]+1][ptr-pt[nm]-1]));

		}

	}

	dp[x]=mul(dp[x],res[ptr+1][n-ptr]);

	printf("%d",dp[x]);

}

#include <bits/stdc++.h>

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, x;
  std::cin >> n >> x;
  std::vector<int64_t> s(n);
  std::cin >> s;
  std::sort(s.begin(), s.end(), std::greater<int64_t>());

  constexpr int64_t mod = 1000000007;

  std::vector<int64_t> t1(100001, 0), t2(100001, 0);

  t1[x] = 1;

  for (int64_t i = 0; i < n; i++) {
    std::fill(t2.begin(), t2.end(), 0);
    for (int64_t j = 0; j < 100001; j++) {
      t2[j % s[i]] += t1[j] % mod;
      t2[j % s[i]] %= mod;
      t2[j] += t1[j] * (n - i - 1);
      t2[j] %= mod;
    }
    std::swap(t1, t2);
  }

  int64_t ans = 0;

  for (int64_t j = 0; j < 100001; j++) {
    ans += j * t1[j] % mod;
    ans %= mod;
  }

  std::cout << ans << std::endl;

  return 0;
}


// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
const int N = 16;
const ll MN = -1e9*N;
int n;
int a[N][N];
ll dp[(1<<N)];
ll value[(1<<N)];
int arr[N];
ll solve(int msk = (1<<n)-1)
{
  if (!msk)return 0;
  ll &ret = dp[msk];
  if (~ret)return ret;
  ret = MN;
  for (int cur_msk = msk; cur_msk; cur_msk=(cur_msk-1)&msk)
  {
    ret = max(ret, value[cur_msk] + solve(msk^cur_msk));
  }
  return ret;
}
ll get_cost(int sz)
{
  ll ret = 0;
  for (int i = 0; i < sz; i++)
    for (int j = i+1; j < sz; j++)
      ret += a[arr[i]][arr[j]];
  return ret;
}
int main()
{
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      scanf("%d", a[i]+ j);
  memset(dp, -1, sizeof dp);
  for (int i = 0; i < (1<<n); i++)
  {
    int idx = 0;
    for (int j = 0; j < n; j++)
    {
      if (i & (1<<j))arr[idx++] = j;
    }
    value[i] = get_cost(idx);
  }
  printf("%lld\n", solve());
}

#include<iostream>
#include<vector>
#include<cmath>
#include<cassert>
#include<bitset>
using namespace::std;
#define int long long int
int dp[1<<16],ar[20][20];

main(){
	ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>ar[i][j];
	for(int j=1;j<(1<<n);j++){
			int t=j;
			vector<int> v;
			for(;t;t-=t&(-t))
				v.push_back((int)log2(t&(-t)));
			// cout<<(bitset<20>)j<<'\n';
			t=j;
			for(int i=0;i<v.size();i++)
				for(int j=i+1;j<v.size();j++)
					dp[t]+=ar[v[i]][v[j]];//,cout<<v[i]<<' '<<v[j]<<' '<<ar[v[i]][v[j]]<<' '<<dp[t]<<'\n';
			// for(auto a:v)
			// 	cout<<a<<' ';
			// cout<<dp[j]<<'\n';
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<(1<<n);j++)
			if(__builtin_popcount(j)==i)
				for(int k=((1<<n)-1)^(((1<<n)-1)&j);k;k--,k^=k&j){
						dp[j|k]=max(dp[j|k],dp[j]+dp[k]);
					}
	cout<<dp[(1<<n)-1]<<'\n';
	// for(int j=1;j<(1<<n);j++)
	// 	cout<<dp[j]<<'\n';
}


#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 all(a) a.begin(),a.end()
#define pb push_back
#define eb 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);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=998244353;
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 noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
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){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi fac,finv,inv;
void init(ll n) {
    fac=vi(n+5);finv=vi(n+5);inv=vi(n+5);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    REP(i,2,n+5){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
long long modcom(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(){
    ll k,n;cin>>k>>n;
    init(n+k);
    REP(j,2,2*k+1){
        ll ans=0;
        ll a=min((j-1)/2,(k*2-j+1)/2),b=(j+1)%2;
        rep(i,a+1)ans=(ans+modcom(a,i)*modpow(2,i)%mod*(modcom(n+k-a*2-b-1,k-a*2-b+i-1)+modcom(n+k-a*2-b-2,k-a*2-b+i-1)*b))%mod;
        out(ans);
    }
}

#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
// 型シノニム
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
// 定数
constexpr ll INF   = 1e16;
constexpr ll INM   = 114514;
constexpr ll MOD   = 1e9 + 7;
constexpr ld EPS   = 1e-12;
constexpr ll dx[4] = {1, 0, -1, 0};
constexpr ll dy[4] = {0, 1, 0, -1};
// 便利関数
void IOS() { ios::sync_with_stdio(false), cin.tie(0); }
template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, ll t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll mod) {
	if (a > 0) return a % mod;
	if (a % mod == 0) return 0;
	ll x = -a / mod + 1;
	a += x * mod;
	return a % mod;
}
ll powm(ll a, ll b, ll m) {
	if (b == 0) {
		return 1;
	} else if (b % 2 == 0) {
		ll d = powm(a, b / 2, m);
		return (d * d) % m;
	} else {
		return (powm(a, b - 1, m) * a) % m;
	}
}
// 本体

int main() {
	IOS();
	ll n, m;
	cin >> n >> m;
	ll dif = (n - 1) / 2;
	ll lb = 1, ub = dif + 1;
	ll cnt = 0;
	while (lb < ub && cnt < m) {
		cout << lb << " " << ub << endl;
		lb++;
		ub--;
		cnt++;
	}
	lb = dif + 2;
	ub = 2 * dif + 1;
	while (lb < ub && cnt < m) {
		cout << lb << " " << ub << endl;
		lb++;
		ub--;
		cnt++;
	}
}


#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int T;
  cin >> T;
  while (T--) {
    int N;
    cin >> N;
    long long A[N];
    for (int i = 0; i < N; i++) cin >> A[i];
    string S;
    cin >> S;
    int ans = 0;
    vector<long long> bases;
    for (int i = N - 1; i >= 0; i--) {
      for (auto b : bases) A[i] = min(A[i], A[i] ^ b);
      if (A[i]) {
        if (S[i] == '1') {
          ans = 1;
          break;
        }
        bases.push_back(A[i]);
      }
    }
    cout << ans << '\n';
  }
  return 0;
}

#include <bits/stdc++.h>

using namespace std;
#define int long long
int po[63];
int f(int x)
{
    for(int i=62;i>=0;i--)
    {
        if(po[i] & x)
        {
            return i;
        }
    }
    return -1;
}
vector <int> basis(vector <int> v)
{
    if(v.size()==1) return v;
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    if(v[0]==0)
    {
        vector <int> ans;
        return ans;
    }
    int n=v.size();
    vector <int> g;
    for(int i=1;i<n;++i)
    {
        if(f(v[i])==f(v[0]))
        {
            v[i]=v[i]^v[0];
        }
        g.push_back(v[i]);
    }
    vector <int> ans=basis(g);
    ans.insert(ans.begin(),v[0]);
    return ans;
}
bool can(vector <int> v,int x)
{
    int n=v.size();
    for(int i=0;i<n;++i)
    {
        if(x==0)
        {
            return true;
        }
        if(f(x)==f(v[i]))
        {
            x^=v[i];
        }
    }
    return (x==0);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int u=1;
    for(int i=0;i<63;++i)
    {
        po[i]=u;
        u*=2;
    }
    int t;
    cin>>t;
    while(t--)
    {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
    }
    string s;
    cin>>s;
    vector <int> v;
    bool h=true;
    for(int i=(n-1);i>=0;i--)
    {
        if(s[i]=='0')
        {
            v.push_back(a[i]);
            v=basis(v);
        }
        else
        {
            if(!can(v,a[i]))
            {
                 h=false;
                 break;
            }
        }
    }
    if(h)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<1<<endl;
    }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};

int main() {
    int n; cin >> n;
    vector<ll> l(n);
    rep(i,n) cin >> l[i];
    int ans = 0;
    rep(i,n) {
        for (int j=i+1; j<n; j++) {
            for (int k=j+1; k<n; k++) {
                if (l[i]==l[j] || l[j]==l[k] || l[k]==l[i]) continue;
                if (l[i]+l[j]>l[k] && l[j]+l[k]>l[i] && l[k]+l[i]>l[j]) ans++;
            }
        }
    }
    cout << ans << endl;
}

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

bool check(int a,int b,int c)
{
    if((a+b)>c && (c+b)>a && (a+c)>b)
        return true;
    return false;
}

int main()
{
    // freopen("input01.txt", "r", stdin);
    // freopen("output01.txt", "w", stdout);
    int n;
    cin>>n;
    map<ll int,int> mp;
    ll int a;
    int l,ct=0;
    for(l=0;l<n;l++)
    {
        cin>>a;
        mp[a]++;
    }

    if(mp.size()<3)
    {
        cout<<0;
        return 0;
    }

    for(auto i=mp.begin();next(next(i))!=mp.end();i++)
    {
        for(auto j=next(i);next(j)!=mp.end();j++)
        {
            for(auto k=next(j);k!=mp.end();k++)
            {
                if(check(i->first,j->first,k->first))
                    ct+=(i->second*j->second*k->second);
            }
        }
    }

    cout<<ct;
    return 0;
}