#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if (a==c&&b==d){
        cout<<0;
        return 0;
    }
    if (a+b==c+d){
        cout<<1;
        return 0;
    }
    if (a-b==c-d){
        cout<<1;
        return 0;
    }
    if (abs(a-c)+abs(b-d)<=3){
        cout<<1;
        return 0;
    }
    if ((a+b)%2==(c+d)%2)
    {
        cout<<2;
        return 0;
    }
    if (abs(abs(a-b)-abs(c-d))<=5){
     cout<<2;
     return 0;
    }
    if (abs(abs(a+b)-abs(c+d))<=5){
     cout<<2;
     return 0;
    }
    cout<<3;

}

#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define rep(i, n) FOR(i,0,n)
#define irep(i, n) IFOR(i,0,n)
#define all(v) begin(v), end(v)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
using VI = vector<int>;
using VLL = vector<ll>;
using VB = vector<bool>;
using VP = vector<P>;
using Graph2 = vector<vector<int>>;
using PQ = priority_queue<int>;
template<typename T>istream& operator>>(istream&s,vector<T>&v){for(auto &i: v)s>>i;return s;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
bool second_compare(P a,P b){if(a.second!=b.second){return a.second<b.second;} else return true;}

int main() {
    ll x, y, z;
    cin >> x >> y >> z;
    for(ll i = 1001 * 1001; i >= 0; i--) {
        if (y*z > i*x) {
            cout << i << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


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

using ll = long long;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n,m;
	cin>>n>>m;

	if(n==1&&m==0)
	{
		cout << "1 2\n";
		return 0;
	}

	if(m<0 || m>=n-1)
	{
		cout << -1 << endl;
		return 0;
	}

	int diff = m+1;
	cout << 1 << " " << diff*2 + 2 << endl;
	n--;

	int cur=2;

	while(diff--)
	{
		cout << cur << " " << cur+1 << "\n";
		cur+=2;
		n--;
	}

	cur++;

	while(n--)
	{
		cout << cur << " " << cur+1 << "\n";
		cur+=2;
	}
}

#include<bits/stdc++.h>
using namespace std;
namespace IO
{
	const int buffer_size=1e5+5;
	char buf[buffer_size],*S,*T;
	bool flag_EOF;
	inline char read_char()
	{
	    if(S==T)
			T=(S=buf)+fread(buf,1,buffer_size,stdin);
	    return S!=T?*(S++):EOF;
	}
	inline int read_int()
	{
	    int flag=1;
	    char c=read_char();
	    while(c<'0'||c>'9')
	    {
	        if(c==EOF)
	        {
	            flag_EOF=true;
	            return 0;
	        }
	        flag=(c=='-'?-1:1);
	        c=read_char();
	    }
	    int x=0;
	    while(c>='0'&&c<='9')
	    {
	        x=x*10+(c^48);
	        c=read_char();
	    }
	    return x*flag;
	}
	char st[13];
	int _top;
	inline void Write(int x)
	{
		if(!x)
		{
			putchar('0');
			return;
		}
		if(x<0)
		{
			putchar('-');
			x=-x;
		}
		while(x)
		{
			st[++_top]=x%10+'0';
			x/=10;
		}
		while(_top>0)
			putchar(st[_top--]);
	}
}
const int max_N=2e5+5;
int a[max_N],b[max_N],p[max_N],id[max_N],pos[max_N];
inline bool cmp(int x,int y)
{
	return b[x]>=b[y];
}
typedef pair<int,int> P;
vector<P> ans;
int main()
{
	int N;
	scanf("%d",&N);
	for(int i=1;i<=N;++i)
		scanf("%d",a+i);
	for(int i=1;i<=N;++i)
		scanf("%d",b+i);
	for(int i=1;i<=N;++i)
	{
		scanf("%d",p+i);
		if(a[i]<=b[p[i]]&&p[i]!=i)
		{
			puts("-1");
			return 0;
		}
		id[p[i]]=i;
		pos[i]=i;
	}
	sort(pos+1,pos+N+1,cmp);
	for(int t=1;t<=N;++t)
	{
		int i=pos[t];
		if(p[i]==i)
			continue;
		int x=id[i];
		ans.push_back(P(i,x));
		swap(id[p[i]],id[p[x]]);
		swap(p[i],p[x]);
	}
	printf("%d\n",int(ans.size()));
	for(int i=0;i<int(ans.size());++i)
		printf("%d %d\n",ans[i].first,ans[i].second);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vint> vvint;
typedef vector<bool> vbool;
typedef vector<vbool> vvbool;
typedef pair<ll, ll> iPair;
#define ff first
#define ss second
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// Use 'cpp_int' instead of 'int'

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

	// freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

	ll n, x;
	string s;
	cin >> n >> x >> s;
	for(auto i:s){
		x = (i == 'o') ? x + 1 : max(0ll, x - 1);
	}
	cout << x;

	return 0;
}

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

int main() {
  int n, x;
  cin >> n >> x;

  rep(i,n){
    char s;
    cin >> s;
    if(s=='o'){
      x++;
    }
    else if(s=='x' && x>0){
      x--;
    }
  }

  cout << x << endl;
}


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

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

  int cn = min(n, 8);
  vector<long long> a(cn);

  for (int i = 0; i < cn; i++) {
    cin >> a.at(i);
  }

  int tmp_1 = 0, tmp_2;
  vector<int> r(200, 0);
  for (int tmp = 1; tmp < (1 << cn); tmp++) {
    long long sum = 0;
    for (int i = 0; i < cn; i++) {
      if (tmp & (1 << i)) {
        sum = (sum + a.at(i)) % 200;
      }
    }
    if (r.at(sum) != 0) {
      tmp_1 = tmp;
      tmp_2 = r.at(sum);
      break;
    }
    r.at(sum) = tmp;
  }

  if (tmp_1 == 0) {
    cout << "No" << endl;
    return 0;
  }

  vector<int> b(0);
  vector<int> c(0);
  for (int i = 0; i < cn; i++) {
    if (tmp_1 & (1 << i)) b.push_back(i + 1);
    if (tmp_2 & (1 << i)) c.push_back(i + 1);
  }

  cout << "Yes" << endl;

  cout << b.size();
  for (int i = 0; i < (int)b.size(); i++) {
    cout << " " << b.at(i);
  }
  cout << endl;

  cout << c.size();
  for (int i = 0; i < c.size(); i++) {
    cout << " " << c.at(i);
  }
  cout << endl;

  return 0;
}

#include <bits/stdc++.h>

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

using namespace std;

vector<string> dfs(int n){
	if(n==1) return {"AB"};

	vector<string> res;
	for(string s:dfs(n-1)){
		string t1,t2;
		for(char c:s){
			if(c=='A') t1+="AA", t2+="AB";
			else       t1+="BB", t2+="BA";
		}
		res.emplace_back(t1);
		res.emplace_back(t2);
	}

	string s;
	rep(i,1<<n-1) s+="AB";
	res.emplace_back(s);

	return res;
}

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

	auto ans=dfs(n);
	cout<<ans.size()<<'\n';
	for(string s:ans) cout<<s<<'\n';

	return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N), B(N);
    REP(i,0,N) cin >> A[i] >> B[i];

    ll sum = 0;
    REP(i,0,N) {
        sum += (B[i] - A[i] + 1) * (A[i] + B[i]) / 2;
    }
    PR(sum);

    return 0;
}

/*

*/

//Work should be challenging and challange should be fun

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
    ll a,b;
    cin>>a>>b;
    cout<<(a+b)/2<<" "<<(a-b)/2;
}


#include<bits/stdc++.h>
using namespace std;
#define   sc(x) scanf("%d",&x)
#define   scll(x) scanf("%lld",&x)
#define   pb  push_back
#define   mp make_pair
#define   nl endl
#define   all(v) v.begin(), v.end()
#define   show(v) for(int x:v) cout<<x<<" "
#define   input(v) for(auto &x:v) cin>>x;
#define   send return

typedef  long long int lli;
typedef  long long  ll;

void solve(){
/*int n;
cin>>n;
vector<int> c(n),a(n),b(n);
input(c);
input(a);
input(b);
for(int i=1;i<n;i++){
    m.pb({a[i],b[i]});
}
int ans = 0,ANS = 0;
for(int i=1;i<=n;i++){
      if(i==1){
        ans += abs(a[i] - b[i]);

      }
      //else if(m[i].first == m[i].second) ANS = max(ans+c[i]-1,ANS),ans = 0;
    else if(i==n){
        ans += c[n-1]-1;
        ANS = max(ans,ANS);
    }

      else{
             ans += (c[i]-1) - abs(a[i] - b[i]);
             if(a[i] == b[i]){
                   ANS = max(ans,ANS);
                   ans = 0;
                }

      }
      ans+=2;
}

cout<<ANS;
int a,b,c;
cin>>a>>b>>c;
while(a>0 && b>0){
    if(c==0) a--,c=1;
    else if(c == 1) b--,c=0;
}
if(a==0) cout<<"Aoki";
else cout<<"Takahashi";*/
int n,s,d;
cin>>n>>s>>d;

for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;

       if(a<s && b>d) {
       cout<<"Yes";
       return;
    }
}

 cout<<"No";
/*int n,m;
cin>>n>>m;
vector<pair<int,int>> h;
while(m--){
        int a,b;
      cin>>a>>b;
    h.pb({a,b});
}
int k;
cin>>k;
unordered_map<int,int> f;
while(k--)
{ int a,b;
  cin>>a>>b;
  f[a]++;
  f[b]++;
}
int cnt = 0;
for(pair<int,int> p : h){
    if(f[p.first] && f[p.second]) cnt++;
}
cout<<cnt;*/
}
int main(){

//lli t;
//scll(t);
//while(t--){
    solve();
    cout<<nl;
//}
}

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define int long long
#define fi(i,n) for(int i=0;i<n;i++)
#define f(i, a, b) for(int i=a;i<b;i++)
#define vi vector<int>
#define pb push_back
#define MOD 1000000007
#define pii pair<int, int>
#define ff first
#define ss second
#define setzero(a) memset(a,0,sizeof(a))
#define prDouble(x) cout<<fixed<<setprecision(10)<<x;
#define SetBits(x) __builtin_popcount(x)
#define in_range(x, y, r, c) (x >= 0 && x < r && y >= 0 && y < c)
ll digits(ll n)
{
    return floor(log10(double(n))) + 1;
}
void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
ll modularExponentiation(ll x,ll n,ll M)
{
    ll result = 1;
    while(n>0)
    {
        if(n % 2 ==1)
        {
            result = ((result%M)*(x%M))%M;
        }
        x  = ((x%M)*(x%M))%M;
        n = n/2;
    }
    return result%M;
}
bool ispower(int n)
{
    if(n%2==1)
        return false;
    while(n>0)
    {
        if(n%2 == 1)
            return false;
        n = n/2;
    }
    return true;
}
int binomialCoeff(int n, int k)
{
    int C[n + 1][k + 1];
    int i, j;
    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {
            // Base Cases
            if (j == 0 || j == i)
                C[i][j] = 1;
            else
                C[i][j] = ((C[i - 1][j - 1])%MOD + (C[i - 1][j])%MOD)%MOD;
        }
    }
    return C[n][k]%MOD;
}
int32_t main()
{
    int n,s,d;
    cin>>n>>s>>d;
    bool ans = false;
    fi(i,n)
    {
        int x,y;
        cin>>x>>y;
        if(x < s && y > d)
            ans = true;
    }
    if(ans)
        cout<<"Yes";
    else
        cout<<"No";
}


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

int main() {
    int si,sj,score[50][50],id[50][50];
    bool ok_id[2500];
    cin >> si >> sj;
    for(int i=0;i<50;i++)
    {
        for(int j=0;j<50;j++)
        {
            cin >> id[i][j];
            ok_id[i*50+j]=true;
        }
    }
    for(int i=0;i<50;i++)
    {
        for(int j=0;j<50;j++)
        {
            cin >> score[i][j];
        }
    }
    bool move_judge[4];
    while(1)
    {
        move_judge[0]=true;//U ↑
        move_judge[1]=true;//D ↓
        move_judge[2]=true;//L ←
        move_judge[3]=true;//R →
        if(si==0)move_judge[0]=false;//上端
        if(si==49)move_judge[1]=false;//下端
        if(sj==0)move_judge[2]=false;//左端
        if(sj==49)move_judge[3]=false;//右端
        int now_id = id[si][sj];
        ok_id[now_id] = false;

        if(move_judge[0])
            if(ok_id[id[si-1][sj]]==false)
                move_judge[0] = false;
        if(move_judge[1])
            if(ok_id[id[si+1][sj]]==false)
                move_judge[1] = false;
        if(move_judge[2])
            if(ok_id[id[si][sj-1]]==false)
                move_judge[2] = false;
        if(move_judge[3])
            if(ok_id[id[si][sj+1]]==false)
                move_judge[3] = false;

        if(move_judge[0]){
            printf("U");
            si-=1;
            continue;
        }else if(move_judge[1]){
            printf("D");
            si+=1;
            continue;
        }else if(move_judge[2]){
            printf("L");
            sj-=1;
            continue;
        }else if(move_judge[3]){
            printf("R");
            sj+=1;
            continue;
        }else{
            break;
        }
    }
    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std ;

void ABC203_C(){
    long long int N,K;
    cin >> N >> K;

    // 単純に記憶するだけではだめ。
//    vector<int> friendPoint(1000000000000000000,0);
    vector<pair<long long int, long long int>> A(N);

    for(int i = 0; i < N; i++){
        cin >> A[i].first >> A[i].second;
    }

    sort(A.begin(),A.end());
    for(int i = 0; i < N; i++){
        if(A[i].first > K){
            break;
        }
        K += A[i].second;
    }

    cout << K << endl;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    ABC203_C();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<pair<int, int>>> E(N);
  for (int i = 0; i < M; i++){
    int A, B, C;
    cin >> A >> B >> C;
    A--;
    B--;
    E[A].push_back(make_pair(C, B));
  }
  for (int i = 0; i < N; i++){
    vector<int> d(N, -1);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    pq.push(make_pair(0, i));
    while (!pq.empty()){
      int dd = pq.top().first;
      int v = pq.top().second;
      pq.pop();
      if (d[v] == -1){
        if (dd > 0){
          d[v] = dd;
        }
        for (auto P : E[v]){
          int w = P.second;
          if (d[w] == -1){
            pq.push(make_pair(dd + P.first, w));
          }
        }
      }
    }
    cout << d[i] << endl;
  }
}

#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  int N;
  ll C;
  cin >> N >> C;
  vector<int> a(N), b(N), c(N);
  set<int> s;
  map<int, ll> changes;
  for (int i = 0; i < N; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    // We only need a[i] and b[i]+1 to represent the final segments.
    // For example, [1, 4] and [3, 8] will make
    // [1, 2], [3, 4], [5, 8] and [9, +inf).
    // They can also be seen as [1, 3), [3, 5), [5, 9) and [9, +inf].
    // We need 1, 3, 5, and 9 to represent these segments.
    s.insert(a[i]), s.insert(b[i] + 1);
    // We use a map to store the change of cost on each critical day.
    changes[a[i]] += c[i];
    changes[b[i] + 1] -= c[i];
  }
  vector<int> v(s.begin(), s.end());
  int M = v.size();
  ll ans = 0, acc = 0;
  for (int i = 0; i < M - 1; ++i) {
    // Deal with the starting and ending of segments.
    acc += changes[v[i]];
    // Add to the total cost.
    ans += min(C, acc) * (v[i + 1] - v[i]);
  }
  cout << ans;
}


#include <bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define sz(s) s.size()
#define PI acos(-1)
using namespace std;
void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    fast();

    int n; cin >> n;
    cout << n - 1 << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  if(n<=1)
    	cout<<"0";
	else
      cout<<n-1;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  if(N%2==0) cout << "White" << endl;
  else cout << "Black" << endl;
}

#include <iostream>
using namespace std;
int main(){

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

    int n;
    cin>>n;
    if(n%2==0){
    	cout<<"White"<<endl;
    }
    else{
    	cout<<"Black"<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define speed ios_base::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);
#define endl "\n"
#define mod 1000000007
//const ld PI  = 3.141592653589793;

bool isPrime(int n)
{
    // Corner cases
    if(n<=3){
        return true;
    }
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}

int main()
{
    speed
    int n;
    cin>>n;
    cout<<n-1;
    return 0;
}

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i <= n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n)
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
using Edge = pair<int, ll>;
const int MAX = 100000;
const ll INF = 1LL << 60;

int main()
{
    // cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a;
    cin >> a;
    cout << a-1 << "\n";
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define X first
#define Y second
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
#define pf(a) cout<<"checking-- "<<a<<endl
#define pff(a,b) cout<<"Checking-- "<<a<<' '<<b<<endl
#define pfff(a,b,c) cout<<"Checking-- "<<a<<' '<<b<<' '<<c<<endl
#define clr(ar) memset(ar,0,sizeof(ar))
#define gP(n) (prime[n>>6]&(1<<((n>>1)&31)))
#define sP(n) (prime[n>>6]=prime[n>>6]|(1<<((n>>1)&31)))
#define on(val,pos) (val|(1<<pos))
#define off(val,pos) (val&(~(1<<pos)))
#define check(val,pos) (val&(1<<pos))
#define invert(val,pos) (val^(1<<pos))
#define INF (ll) 1e18
#define pie (double)acos(-1.0)
#define vsort(v) sort(v.begin(),v.end())
#define arsort(v,n) sort(v,v+n)
#define MAX 100004
#define MOD 1000000007
vector<tuple<int,int,int>> edges;

void solve(){
    ll n,w; cin>>n>>w;
    cout<<n/w<<endl;

}
int main(){
    int tst=1;
    while(tst--){
        solve();
    }

    return 0;
}

#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#include<vector>
#include<iterator>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<list>
#include<algorithm>
#include<sstream>
#define PI acos(-1)
typedef long long ll;
#define V(dt) vector

#define S(dt) set

#define L(dt) list

#define M(dt1,dt2) map<dt1,dt2>
#define ST(dt) stack

#define Q(dt) queue

#define DQ(dt) deque

#define I ::iterator
#define P(dt1,dt2) pair<dt1,dt2>
#define VP(dt1,dt2) vector< pair<dt1,dt2> >
#define A int ii,tt; cin>>tt; for(ii=0;ii<tt;ii++)
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define INTMAX 2147483647
#define INTMIN -2147483648
//int sum=0;
using namespace std;
int main()
{
    int n,w;
    cin>>n>>w;
    for(int i=1;;i++){
        if((i*w)==n){
            cout<<i<<endl;
            return 0;
        }
        if((i*w)>n){
            cout<<i-1<<endl;
            return 0;
        }
    }

}


//#define DEBUG
//#define OPTIMIZE
//#define INTERACTIVE

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

#include <bits/extc++.h>
using namespace __gnu_pbds;

const int MAXN = 100;
const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = LONG_LONG_MAX;
#define INIT(arr, val) fill(arr, arr+(int)(sizeof(arr)/sizeof(arr[0])), val)
#define REP(i, lb, rb, inc) for(int i = (lb); i < (rb); i += inc)
#define RREP(i, rb, lb, dec) for(int i = (rb)-1; i >= (lb); i -= dec)
typedef long long ll;
typedef queue<int> QI;
typedef vector<int> VI;
#define pb push_back
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define X real()
#define Y imag()
#define ALL(x) x.begin(), x.end()
#define OUT(x) {x; cout<<endl;}

#ifdef DEBUG
#	define dbg(x) x
#else
#	define dbg(x)
#endif

#ifdef OPTIMIZE
#	pragma GCC optimize("Ofast")
#	pragma GCC target("avx,avx2,fma")
#endif

#ifndef INTERACTIVE
#	define endl '\n'
#	define Foxyy cin.tie(0); cout.sync_with_stdio(0); cout.tie(0);
#endif

#define READ(a, t) t a; cin >> a
#define READARR(arr, n) REP(___i, 0, (n), 1) cin >> arr[___i]
#define PRINTARR(arr, n) REP(___i, 0, (n), 1) cout << arr[___i] << " "; cout << endl

#define RI(a) READ(a, int)
#define RLL(a) READ(a, ll)
#define RSTR(a) READ(a, string)
#define RVI(a, n) VI a(n); READARR(a, n)

tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update> T;

signed main() {
	#ifndef INTERACTIVE
		Foxyy
	#endif

	RI(n);
	VI a(n);
	ll ans = 0;
	REP(i, 0, n, 1) {
		cin >> a[i];
		ans += T.order_of_key(a[i]);
		T.insert(a[i]);
	}
	cout << ans << endl;
	REP(i, 0, n-1, 1) {
		ans -= a[i];
		ans += n-1-a[i];
		cout << ans << endl;
	}
}

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> 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) - 1;
const ll linf = 1LL<<61;
const int MAX = 510000;
int dy[8] = {0,1,0,-1,1,-1,-1,1};
int dx[8] = {-1,0,1,0,1,-1,1,-1};
const double pi = 3.14159265358979;
const double eps = 1e-8;
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){
    int sz = a.size();
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr;
        sz--;
        if(sz) cout << " ";
	}
    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";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    if(s[0] == s.back()){
        for(int i=1; i<n-1; i++){
            if(s[i] != s[0] && s[i+1] != s[0]){
                cout << 2 << endl;
                return 0;
            }
        }
        cout << -1 << endl;
    }else{
        cout << 1 << endl;
    }
}


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef bitset<16> BS;
struct edge {
    int to, cost, id;
};
const double EPS = 1E-09;
const ll MOD = 1E+09 + 7; // =998244353;
const ll INF = 1E18;
const int MAX_N = 1E+05;

ll dx[4] = { -1, 1, 0, 0 }, dy[4] = { 0, 0, -1, 1 };

ll M;

string X;

bool f(ll n);

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

    cin >> X >> M;

    ll d = 0;
    for (auto x : X) {
        d = max(d, (ll)(x - '0'));
    }

    //reverse(X.begin(), X.end());

    ll high = M + 1, low = 0;
    ll ans = 0;
    //ll high = (ll)(pow((double)M / (double)(X[X.size() - 1]), 1.0 / ((double)X.size() - 1.0))) + 100
    if (X.size() > 1) {
        while (true) {
            ll mid = (high + low) / 2;
            if (mid == high || mid == low)
                break;
            if (f(mid)) {
                high = mid;
            } else {
                low = mid;
            }
            //cout << "high = " << high << ", low = " << low << "\n";
        }
    } else {
        if (X[0] - '0' <= M)
            ans = 1;
    }

    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */

    cout << (X.size() == 1 ? ans : max(0LL, low - d)) << "\n";

    return 0;
}

bool f(ll n)
{
    ll res = 0;
    for (auto c : X) {
        ll x = c - '0';
        if (res > M / n)
            return true;
        res = res * n + x;
    }
    //cout << "n = " << n << ", res = " << res << "\n";
    return res > M;
}

// bool f(ll n)
// {
//     vector<ll> res;
//     ll m = M;
//     while (m > 0) {
//         res.push_back(m % n);
//         m /= n;
//     }
//     // cout << "n = " << n << "\n";
//     // cout << "Xsize = " << X.size() << ", res.size = " << res.size() << "\n";
//     if (res.size() != X.size())
//         return X.size() > res.size();

//     reverse(res.begin(), res.end());
//     for (int i = 0; i < X.size(); i++) {
//         ll x = X[i] - '0';
//         if (x > res[i])
//             return true;
//         else if (x < res[i])
//             return false;
//     }
//     return false;
// }

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <limits>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
template<class T> inline int  sz(T &a) { return a.size(); }
using ll = long long; using ld = long double;
using pi = pair<int,int>; using pl = pair<ll,ll>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
const int inf = numeric_limits<int>::max();
const ll infll = numeric_limits<ll>::max();
int main()
{
  string s; cin >> s;
  ll m; cin >> m;
  int n = sz(s);
  ll mx = 0;
  rep(i,n) {
    ll tmp = s[i] - '0';
    chmax(mx, tmp);
  }
  if(n == 1) {
    if(mx <= m) cout << 1 << "\n";
    else cout << 0 << "\n";
    return 0;
  }
  ll lb = mx, ub = 1000000000000000001;
    ll an = s[0] - '0';
  while(ub - lb > 1) {
    ll B = (ub + lb) / 2;
//    cout << B << "\n";
    ll x = an;
    int cnt = 0;
    while(x <= m/B) {
      x *= B;
//      cout << x << "\n";
      cnt++;
      if(cnt == n-1) break;
    }

    if(cnt==n-1) {
      ll sum = 0;
      ll buf = 1;
      for(int j = n-1; j >= 1; --j) {
        ll tmp = s[j] - '0';
        sum += tmp * buf;
        buf *= B;
      }
      if(an*buf <= m - sum) {
        lb = B;
      }
      else ub = B;
    }
    else ub = B;
  }
  cout << lb-mx << "\n";

  return 0;
}


/*
このコード、と～おれ!
Be accepted!
∧＿∧
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
          　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
#include <array>
#include <chrono>

//#pragma GCC target("arch=skylake-avx512")
#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define repeat(i, n, m) for(int i = n; i < (m); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)
#define printLdb(a) printf("%.50Lf\n", a)
#define printdbd(a) printf("%.16lf\n", a)
#define prints(s) printf("%s\n", s.c_str())
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d))

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr ll mod = 998244353;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
    char c;
    str = "";
    scanf("%c", &c);
    if (c == '\n')scanf("%c", &c);
    while (c != '\n' && c != -1 && c != ' ') {
        str += c;
        scanf("%c", &c);
    }
}

void scanc(char& str) {
    char c;
    scanf("%c", &c);
    if (c == -1)return;
    while (c == '\n') {
        scanf("%c", &c);
    }
    str = c;
}

double acot(double x) {
    return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

template<typename T>
inline T chmin(T& a, const T& b) {
    if (a > b)a = b;
    return a;
}

template<typename T>
inline T chmax(T& a, const T& b) {
    if (a < b)a = b;
    return a;
}

//cpp_int
#if __has_include(<boost/multiprecision/cpp_int.hpp>)
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace boost::multiprecision;
#else
using cpp_int = ll;
#endif

//atcoder library
#if __has_include(<atcoder/all>)
#include <atcoder/all>
//using namespace atcoder;
#endif

/*
    random_device seed_gen;
    mt19937 engine(seed_gen());
    uniform_int_distribution dist(1, 100);
*/

/*----------------------------------------------------------------------------------*/

int main() {

    ll n;
    scanf("%lld", &n);
    ll a = 0, b = 62, c = 0, d = (1ll << 62ll), ans = n;
    while (n < d) {
        d >>= 1;
        --b;
    }
    do {
        a = n / d;
        c = n - a * d;
        chmin(ans, a + b + c);
        d >>= 1;
    } while (b--);

    printf("%lld\n", ans);

    Please AC;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
ll inf = 1ll << 60;
int main(){
     ll n;
     cin >> n;
     ll ans = inf;
     for (int i = 0; i < 61; i++){
          ll p = 1ll << i;
          ll a = n / p, b = n % p;
          ans = min(ans, a + b + i);
     }
     cout << ans;
}


//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T>>;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

char str[] = "UNSATISFIABLE";

//head

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, w;
  cin >> a >> b >> w;
  w *= 1000;
  int l = 0, r = 0;
  int cnt = 0;
  int mi = INF, ma = 0;
  while(l <= w) {
    if(w <= r) {
      chmin(mi, cnt);
      chmax(ma, cnt);
    }
    l += a;
    r += b;
    cnt++;
  }
  if(mi == INF) puts(str);
  else cout << P(mi, ma) << endl;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
  long long A,B,C,D;
  cin>>A>>B>>C>>D;
  long long sum=A+B+C+D;
  if(A==sum-A||B==sum-B||C==sum-C||D==sum-D||A+B==C+D||A+C==B+D||A+D==B+C){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;

  return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <set>
#include <time.h>
#include <sstream>
#include <queue>
using namespace std;
using ll=long long;
void print(int *some_list,int many){
  cout << "[";
  for (int i=0;i<many;i++){
    cout << some_list[i] << ", ";
  }
  cout << "]" << "  要素数:" << many << endl;
}

string bit(int a,int base=2){
  int b;
  string s="";
  for(int i=0;a>0;i++){
    b=a%base;
    a-=b;
    a/=base;
    char num='0'+b;
    s.push_back(num);
  }
  reverse(s.begin(),s.end());
  return s;
}

int main(){
  ll ans=0,n;
  cin >> n;
  for(int i=0;i<n;i++){
    ll many;
    cin >> many;
    if(many>10) ans+=many-10;
  }
  cout << ans << endl;
}

#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define qll queue<ll>
#define sll set<ll>
//(a/b)%mod = (a%mod*powermod(b,mod-2,mod))%mod
ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                    //n is odd
        return x*power(x*x,(n-1)/2);
}
int highestPowerof2(int n)
{
    int p = (int)log2(n);
    return (int)pow(2, p);
}
ll powermod(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
return res;
}
vector<string>s(70);
ll n;
ll dp[70][70];
ll trav(ll i,bool x,bool prev){
	if(i==n && prev) return 1;
	if(i==n) return 0;
	if(dp[i][prev]!=-1) return dp[i][prev];
	if(s[i]=="AND"){
		return dp[i][prev]=trav(i+1,true,prev&true)+trav(i+1,false,prev&false);
	}
	else{
		return dp[i][prev]=trav(i+1,true,prev|true)+trav(i+1,false,prev|false);
	}
}

int main(){
    memset(dp,-1,sizeof(dp));
	cin>>n;
	for(ll i=0;i<n;i++) cin>>s[i];
	ll sum=trav(0,true,true);
	memset(dp,-1,sizeof(dp));
	sum+=trav(0,false,false);
	cout<<sum<<endl;
	return 0;
}


#include <iostream>

using namespace std;

int main()
{
  float N;
  cin >> N;
  if ((int)(N * 1.08) < 206)
    cout << "Yay!";
else if ((int)(N * 1.08) == 206)
    cout << "so-so";
 else
   cout << ":(";
}

/*
 * @author: 0x404
 * @Date: 2021-02-20 19:56:33
 * @LastEditTime: 2021-02-20 20:02:58
 * @Description:
 */

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;

int x;

int main(){
    cin >> x;
    if(x % 100 == 0) cout << 100 << endl;
    else {
        for(int i = 1; i <= 100000; i++){
            if((x + i) % 100 == 0){
                cout << i << endl;
                return 0;
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define M 1005
typedef long long ll;
using namespace std;
int stp[M][M][27];
int n,m;
vector<int> E[M][26];
struct node{int x,y,c;};
queue<node> Q;
int BFS(){
	int x,y,c;
	while(!Q.empty()){
		x=Q.front().x;
		y=Q.front().y;
		c=Q.front().c;
		if((c==26)&&((x==1&&y==n)||(x==n&&y==1)))return stp[x][y][26];
		Q.pop();
		if(c==26){
			for(int i=0;i<26;++i)
				for(int j=0,z;j<E[x][i].size();++j){
					if(~stp[z=E[x][i][j]][y][i])continue;
					stp[z][y][i]=stp[x][y][c]+1;
					Q.push((node){z,y,i});
				}
		}else{
			for(int j=0,z;j<E[y][c].size();++j){
				if(~stp[x][z=E[y][c][j]][26])continue;
				stp[x][z][26]=stp[x][y][c]+1;
				Q.push((node){x,z,26});
			}
		}
	}
	return -1;
}
int main(){
	cin>>n>>m;
	memset(stp,-1,sizeof(stp));
	for(int i=1;i<=n;++i){
		stp[i][i][26]=0;
		Q.push((node){i,i,26});
	}
	int u,v;char c[5];
	for(int i=1;i<=m;++i){
		scanf("%d%d%s",&u,&v,c);
		if(u>v)swap(u,v);
		E[u][c[0]-'a'].push_back(v);
		E[v][c[0]-'a'].push_back(u);
		if(u==v)continue;
		stp[u][v][26]=1;
		stp[v][u][26]=1;
		Q.push((node){u,v,26});
		Q.push((node){v,u,26});
	}
	cout<<BFS();
	return 0;
}

//
// Created by yamunaku on 2021/03/27.
//

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

using namespace std;
//using namespace atcoder;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main() {
    //CFS;
    int n, m;
    cin >> n >> m;
    vector<vector<vector<int>>> e(n, mti(26));
    priority_queue<pair<int, pair<int, int>>> q;
    rep(i, n) q.push({0, {i, i}});
    rep(i, m) {
        int a, b;
        char c;
        cin >> a >> b >> c;
        a--, b--;
        c -= 'a';
        e[a][c].push_back(b);
        e[b][c].push_back(a);
        q.push({-1, {a, b}});
        q.push({-1, {b, a}});
    }
    mti len(n, vi(n, IINF));
    while (!q.empty()) {
        auto now = q.top();
        q.pop();
        int x = now.second.first, y = now.second.second;
        if (len[x][y] != IINF) continue;
        len[x][y] = -now.first;
        rep(i, 26) {
            for (auto &nx : e[x][i]) {
                for (auto &ny : e[y][i]) {
                    if (len[nx][ny] != IINF) continue;
                    q.push({-len[x][y] - 2, {nx, ny}});
                }
            }
        }
    }
    if (len[0][n - 1] != IINF) cout << len[0][n - 1] << endl;
    else cout << -1 << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using LL = uint64_t;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a,b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100
#define MAX6 1001001
#define MAX7 10010010
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define MAX_LL LLONG_MAX
#define CLR(mat) memset(mat, 0, sizeof(mat))
template<class T, class U> inline bool chmax(T& a, U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a, U b) { if (a > b) { a = b; return 1; } return 0; }
#define MOD 1000000007
//const ll inf=1e18;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

int main(){
   ll N;
   cin>>N;
   int B=0;
   VI vec;
   for(ll b=5;b<N;b*=5){
      B++;
      ll x=N-b;
      vec.emplace_back(x);
   }
   VI three;
   for(ll a=3;a<N;a*=3){
      three.emplace_back(a);
   }
   for(int i=0;i<sz(vec);i++){
      if(binary_search(ALL(three), vec[i])){
         cout<<distance(three.begin(), lower_bound(ALL(three), vec[i]))+1<<" "<<i+1<<endl;
         return 0;
      }
   }
   cout<<-1<<endl;
   return 0;
}

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

int main() {

  long long N,M;
  cin >> N;

  long long n3 = 1;
  long long n5;

  for (int i=1; i<100; i++) {
    n3 *= 3ll;
    M = N-n3;
    n5 = 1;
    if (M <= 1) {
      cout << -1 << endl;
      return 0;
    }
    for (int j=1; j<100; j++) {
      n5 *= 5;
      if (n5 > M) {
        break;
      }
      if (n5 == M) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }

  return 0;
}


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

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

    pair<long long,int> g[N/2],k[N/2];
    for(int i=0;i<N/2;i++){
        g[i]=make_pair(AB[i*2],i*2);
    }
    for(int i=0;i<N/2;i++){
        k[i]=make_pair(AB[i*2+1],i*2+1);
    }

    sort(g,g+N/2);
    sort(k,k+N/2);

    long long ans=0;
    for(int i=0;i<N/2;i++){
        if(g[i].first+k[i].first<0){
            ans+=B[g[i].second]+B[k[i].second];
        }
        else{
            ans+=A[g[i].second]+A[k[i].second];
        }
    }

    cout<<ans<<endl;
}

#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T x=0,f=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
#define int long long
namespace run{
	const int N=1e5+9;
	int n,a[N],b[N],ans;
	priority_queue<int> pq[2];
	int main(){
		n=read<int>();
		for(int i=1;i<=n;i++) ans+=(a[i]=read<int>());
		for(int i=1;i<=n;i++) b[i]=read<int>();
		for(int i=1;i<=n;i++) pq[i&1].push(b[i]-a[i]);
		while(!pq[0].empty() && !pq[1].empty() && pq[0].top()+pq[1].top()>0){
			ans+=pq[0].top()+pq[1].top();
			pq[0].pop(),pq[1].pop();
		}
		printf("%lld\n",ans);
		return 0;
	}
}
#undef int
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}


#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n, m, cntA, cntB;
  cin >> n >> m >> cntA >> cntB;
  vector<vector<int>> a(n, vector<int>(m));
  vector<vector<int>> dp(n, vector<int>(m));
  for (int i = 0; i < cntA; ++i) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    a[x][y] = 1;
  }
  vector<vector<bool>> b(n, vector<bool>(m));
  for (int i = 0; i < cntB; ++i) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    b[x][y] = true;
  }
  for (int i = 0; i < n; ++i) {
    int cur = 0;
    for (int j = 0; j < m; ++j) {
      if (b[i][j]) {
        cur = 0;
      } else {
        cur += a[i][j];
        dp[i][j] += cur;
      }
    }
    cur = 0;
    for (int j = m - 1; j >= 0; --j) {
      if (b[i][j]) {
        cur = 0;
      } else {
        cur += a[i][j];
        dp[i][j] += cur;
      }
    }
  }
  for (int j = 0; j < m; ++j) {
    int cur = 0;
    for (int i = 0; i < n; ++i) {
      if (b[i][j]) {
        cur = 0;
      } else {
        cur += a[i][j];
        dp[i][j] += cur;
      }
    }
    cur = 0;
    for (int i = n - 1; i >= 0; --i) {
      if (b[i][j]) {
        cur = 0;
      } else {
        cur += a[i][j];
        dp[i][j] += cur;
      }
    }
  }
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (b[i][j]) continue;
      ret += dp[i][j] > 0;
    }
  }
  cout << ret << '\n';
  return 0;
}

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

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

	int n; long long C;
	cin >> n >> C;

	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];

	map<int, vector<int>> mp;
	for (int i = 0; i < n; i++) {
		mp[a[i]].push_back(c[i]);
		mp[b[i] + 1].push_back(-c[i]);
	}

	int last = 0;
	long long ans = 0, cur_cost = 0;

	for (auto &[k, v] : mp) {
		ans += min(C, cur_cost) * (k - last);
		for (auto &x : v) {
			cur_cost += x;
		}
		last = k;
	}
	cout << ans << '\n';
	return 0;
}


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

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    vector<int> a(3);
    cin >> a;
    sort(all(a));
    cout << a[1] + a[2] << "\n";
    return 0;
}

//

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

int main()
{
    int A, B, C, ans = 0;
    cin >> A >> B >> C;
    if(A > B)
    {
        if(B > C)
        {
            ans += B + A;
        }
        else
        {
            ans += C + A;
        }
    }
    else
    {
        if(A > C)
        {
            ans += B + A;
        }
        else
        {
            ans += B + C;
        }
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using PP = pair<int, P>;

const int N = 30;
int T = 0;
int cost[N][N][N][N];
int updated_time[N][N][N][N];
int updates[N][N][N][N];
int visited[N][N][N][N];

char dir(int dx, int dy) {
    if (dx == 0) {
        if (dy > 0) return 'R';
        else return 'L';
    } else {
        if (dx > 0) return 'D';
        else return 'U';
    }
}

pair<vector<P>, string> shortestPath(int sx, int sy, int tx, int ty) {
    vector<vector<int>> dist(N, vector<int>(N, 10000000));
    vector<vector<P>> prev(N, vector<P>(N));
    dist[sx][sy] = 0;

    priority_queue<PP, vector<PP>, greater<PP>> q;
    q.emplace(PP(0, P(sx, sy)));

    vector<int> dx = {-1, 1, 0, 0};
    vector<int> dy = {0, 0, -1, 1};

    while (!q.empty()) {
        PP p = q.top();
        q.pop();
        int d = p.first;
        int x = p.second.first;
        int y = p.second.second;

        if (d > dist[x][y]) continue;

        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx < 0 || nx >= N || ny < 0 || ny >= N) continue;
            d = cost[x][y][nx][ny];

            if (T < 250) {
                // if (T < 10 && ((x + y + T) & 1)) d = 10000;
                if (visited[x][y][nx][ny]) d = 10000;
            }

            if (dist[nx][ny] > dist[x][y] + d) {
                dist[nx][ny] = dist[x][y] + d;
                prev[nx][ny] = P(x, y);
                q.push(PP(dist[nx][ny], P(nx, ny)));
            }
        }
    }

    vector<P> res;
    string out;

    int x, y;
    x = tx; y = ty;

    while (x != sx || y != sy) {
        res.push_back(P(x, y));
        int px, py;
        P prv = prev[x][y];
        px = prv.first;
        py = prv.second;

        visited[x][y][px][py] = 1;
        visited[px][py][x][y] = 1;

        // for (int i = 0; i < 4; i++) {
        //     int nx = x + dx[i];
        //     int ny = y + dy[i];
        //     if (nx < 0 || nx >= N || ny < 0 || ny >= N) continue;

        //     visited[x][y][nx][ny] = 1;
        //     visited[nx][ny][x][y] = 1;
        //     visited[px][py][nx][ny] = 1;
        //     visited[nx][ny][px][py] = 1;
        // }

        out += dir(x - px, y - py);
        x = px; y = py;
    }

    res.push_back(P(sx, sy));

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

    return pair<vector<P>, string>(res, out);
}

void updateCost(vector<P> v, int dist) {
    for (int i = 0; i < (int)v.size() - 1; i++) {
        int x = v[i].first; int y = v[i].second;
        int nx = v[i + 1].first; int ny = v[i + 1].second;
        int up = updates[x][y][nx][ny];
        double r = 1.0 / (1 + up) + (1 - 1.0 / (up + 1)) / (1 + exp(v.size() - 2));
        cost[x][y][nx][ny] = (int)(cost[x][y][nx][ny] * (1 - r) + dist * r);
        cost[nx][ny][x][y] = cost[x][y][nx][ny];
        updates[x][y][nx][ny]++;
        updated_time[x][y][nx][ny] = T;
    }
}

int main() {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                for (int l = 0; l < N; l++) {
                    cost[i][j][k][l] = 5000;
                }
            }
        }
    }

    while (T < 1000) {
        int sx, sy, tx, ty;
        cin >> sx >> sy >> tx >> ty;
        auto [vertices, path] = shortestPath(sx, sy, tx, ty);
        cout << path << endl << flush;
        int dist;
        cin >> dist;
        updateCost(vertices, dist / (vertices.size() - 1));
        T++;
    }
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vz;
typedef vector<vz> vvz;
typedef pair<ll, ll> pll;
#define sz(x) ll((x).size())
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(ll i=(a); i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define F first
#define S second
#define os(x) cout<<x<<' '
#define on(x) cout<<x<<"\n"
#define nl cout<<"\n"
#define maxe(x) max_element(all(x))-(x).begin()
#define mine(x) min_element(all(x))-(x).begin()
const ll P=998244353;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\input1.txt", "r", stdin);
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\output1.txt", "w", stdout);
#endif

	ll h, k, x, y, ans;
	cin>>h>>k>>x>>y;
	x=x-h, y=y-k, h=0, k=0;
	if(x==0 && y==0) ans=0;
	else if(abs(x)+abs(y)<=3 || abs(x)==abs(y)) ans=1;
	else if((y>=x-3 && y<=x+3) || (y>=-x-3 && y<=-x+3)) ans=2;
	else{
		if((x+y)%2) ans=3;
		else ans=2;
	}
	on(ans);
	cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}


#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
#include <cassert>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; exit(0); }
void Yes() { cout << "Yes" << endl; exit(0); }
void No() { cout << "No" << endl; exit(0); }

int N, X;
int A[101];

int memo[101][101];

int func(int target)
{
	REP(i, 101) REP(j, 101) memo[i][j] = -1;
	memo[0][0] = 0;

	for (int n = 0; n < N; n++)
	{
		for (int i = target; i >= 1; i--)
		{
			for (int j = 0; j < target; j++)
			{
				if (memo[i - 1][j] >= 0)
				{
					int val = memo[i - 1][j] + A[n];
					int new_m = (X - val) % target;
					memo[i][new_m] = max(memo[i][new_m], val);
				}
			}
		}
	}

	if (memo[target][0] < 0) return LLONG_MAX;

	int check = (X - memo[target][0]) % target;
	int wait = (X - memo[target][0]) / target;
	return wait;
}

signed main()
{
	cin >> N >> X;
	REP(i, N) cin >> A[i];

	int ans = LLONG_MAX;
	for (int i = 1; i <= N; i++)
	{
		ans = min(ans, func(i));
	}
	cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,T;
  R n;
  P a[n];
  rep(i,n) cin >> a[i].F >> a[i].S;
  ll Mi=-MAXL,Ma=MAXL;
  {
    rep(i,n) {
      if(a[i].S==1) Mi+=a[i].F;
      if(a[i].S==2) Mi=max(Mi,a[i].F);
      if(a[i].S==3) Mi=min(Mi,a[i].F);
    }
    rep(i,n) {
      if(a[i].S==1) Ma+=a[i].F;
      if(a[i].S==2) Ma=max(Ma,a[i].F);
      if(a[i].S==3) Ma=min(Ma,a[i].F);
    }
  }
  ll l=-MAXL,r=MAXL;
  while(l+1<r) {
    ll m=(l+r)/2;
    ll x=m;
    rep(i,n) {
      if(a[i].S==1) x+=a[i].F;
      if(a[i].S==2) x=max(x,a[i].F);
      if(a[i].S==3) x=min(x,a[i].F);
    }
    if(x<=Mi) l=m;
    else r=m;
  }
  ll z=l;
  R T;
  while(T--) {
    ll x;
    R x;
    if(x<z) pr(Mi);
    else pr(min(Ma,x-z+Mi));
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
typedef int64_t ll;
typedef long double ld;
typedef unsigned long long ULL;
#define endl "\n"
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
void read(vector<int> &a) {for (auto &x : a)cin >> x;}
void read(vector<ll> &a) {for (auto &x : a)cin >> x;}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c * x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
    ~debug() { cerr << endl; }
    eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int MOD = 1e9 + 7;
const int INF = (int)2e9 + 7;
const ll LINF = (ll)1e18;
const ld PI = 3.1415926535897932384626433832795;

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b) {
        cout << "=";
    }
    else if (abs(a) == abs(b)) {
        if (c % 2 == 0) {
            cout << "=";
        }
        else if (a > 0 && b < 0) {
            cout << ">";
        }
        else if (b > 0 && a < 0) {
            cout << "<";
        }
        else {
            assert(false);
        }
    }
    else if (a == 0 || b == 0) {
        if (a == 0 && b == 0) {
            cout << "=";
        }
        else if (a == 0) {
            if (b > 0) {
                cout << "<";
            }
            else if (b < 0 && c % 2 == 0) {
                cout << "<";
            }
            else {
                cout << ">";
            }
        }
        else {
            if (a > 0) {
                cout << ">";
            }
            else if (a < 0 && c % 2 == 0) {
                cout << ">";
            }
            else {
                cout << "<";
            }
        }
    }
    else if (a < 0 && b < 0) {
        if (c % 2 == 0) {
            if (abs(a) < abs(b)) {
                cout << "<";
            }
            else {
                cout << ">";
            }
        }
        else if (a < b) {
            cout << "<";
        }
        else {
            cout << ">";
        }
    }
    else if (a > 0 && b > 0) {
        if (a < b) {
            cout << "<";
        }
        else {
            cout << ">";
        }
    }
    else if (a < 0 && b > 0) {
        if (c % 2 == 0) {
            if (abs(a) > abs(b)) {
                cout << ">";
            }
            else {
                cout << "<";
            }
        }
        else {
            cout << "<";
        }
    }
    else if (a > 0 && b < 0) {
        if (c % 2 == 0) {
            if (abs(a) > abs(b)) {
                cout << ">";
            }
            else {
                cout << "<";
            }
        }
        else {
            cout << ">";
        }
    }
}

int32_t main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    auto t1 = high_resolution_clock::now();
    for (int tt = 1; tt <= t; tt++)
    {
        //cout << "Case #" << tt << ": ";
        solve();
    }
    auto t2 = high_resolution_clock::now();
    auto time = duration_cast<duration<double>>(t2 - t1);
    cerr << "Time elapsed = " << time.count() << endl;
}

/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
int N;
int a[SIZE];
int b[SIZE];
int p[SIZE];
int from[SIZE];
void solve() {
    VPII AA;
    FOR(i,1,N){
        if(p[i] != i && a[i] <= b[p[i]]) {
            W(-1);
            return;
        }
        AA.PB(MP(b[p[i]],p[i]));
    }
    sort(ALL(AA),greater<PII>());
    VPII an;
    REP(i,SZ(AA)){
        int x=AA[i].S;
        if(x==p[x])continue;
        int y=from[x];
        an.PB(MP(x,y));
        swap(p[x],p[y]);
        from[p[x]]=x;
        from[p[y]]=y;
    }
    W(SZ(an));
    for(auto x: an) {
        W(x);
    }
}
void input() {
    R(N);
    FOR(i,1,N)R(a[i]);
    FOR(i,1,N)R(b[i]);
    FOR(i,1,N){
        R(p[i]);
        from[p[i]]=i;
    }
}
int main(){
    input();
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define dd long double
#define all(x) x.begin(),x.end()
template<ll MOD = 998244353>
struct mint{
    ll x;
    ll mod = MOD;
    mint(ll x=0):x(x%MOD){}
    mint& operator+=(const mint a){
        if((x+=a.x)>=MOD) x-=MOD;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += MOD-a.x)>=MOD) x-=MOD;
        return *this;
    }
    mint& operator*=(const mint a){
        (x*=a.x)%=MOD;
        return *this;
    }
    mint operator+(const mint a) const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const{
        mint res(*this);
        return res*=a;
    }
    mint power(ll t) const{
        if(!t) return 1;
        mint a = power(t>>1);
        a*=a;
        if(t&1) a*=*this;
        return a;
    }

    mint inv() const{
        return power(MOD-2);
    }
    mint& operator/=(const mint a){
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const{
        mint res(*this);
        return res/=a;
    }
};
template<ll mod>
ostream & operator << (ostream & output,const mint<mod> & a){
        output<<a.x;
        return output;
}
template<ll mod>
istream & operator >> (istream & input, mint<mod>& a){
        input>>a.x;
        return input;
}

using mll=mint<>;
const ll N=1e6;
mll fact[N+1];
mll ifact[N+1];

void init(){
    fact[0]=fact[1]=1;
    FOR(i,2,N+1){
        fact[i]=fact[i-1]*i;
    }
    ifact[0]=1;
    ifact[1]=1;
    ifact[1]/=1;
    FOR(i,2,N+1){
        ifact[i]=1;
        ifact[i]/=i;
        ifact[i]*=ifact[i-1];
    }
}

mll pnc(ll n, ll r){
    mll a=fact[n];
    a*=ifact[r];
    a*=ifact[n-r];
    return a;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    init();
    ll n,m,k;
    cin>>n>>m>>k;
    mll ans=0;
    if(n==1 || m==1){
        ans+=mll(k).power(n*m);
        cout<<ans<<endl;
        return 0;
    }
    for(ll i=1;i<=k;i++){
        mll temp=mll(i).power(n);
        temp-=mll(i-1).power(n);
        temp*=mll(k-i+1).power(m);
        ans+=temp;
    }
    cout<<ans<<endl;
}

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

long long p=998244353;

long long BinaryExpo(long long a,long long b)
{
   a=a%p;
   long long res=1;
   while(b>0)
   {
     if(b&1) res=(res*a)%p;
     b=b>>1;
     a=(a*a)%p;
   }
   return res;
}

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

  long long n,m,k;
  cin>>n>>m>>k;

  if(n>=2 && m>=2)
  {
  	 long long ans=0;
  	 long long prv=0,curr=0;
     for(int i=1;i<=k;i++)
     {
     	curr=BinaryExpo(i,n);

        long long x=(curr-prv+p)%p,y=BinaryExpo(k-i+1,m);
        x=(x*y)%p;
        ans=(ans+x)%p;
     	prv=curr;
     }

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

  if(n==1 && m==1)
  {
  	cout<<k<<"\n";
  	return 0;
  }

  n=max(n,m);
  cout<<BinaryExpo(k,n)<<"\n";

}


#include<bits/stdc++.h>
#define For(i,l,r) for(int i=(l);i<=(r);i++)
#define ReFor(i,r,l) for(int i=(r);i>=(l);i--)
const int MAXN=1010;
using namespace std;
int n,ans;
struct llz
{
	int x,y;
}a[MAXN];
inline int read()
{
	int f=1,x=0;
	char ch=getchar();
	while(ch<'0' || ch>'9')
	{
		if(ch=='-')
			f=-1;
		ch=getchar();
	}
	while(ch>='0' && ch<='9')
	{
		x=(x<<3)+(x<<1)+ch-'0';
		ch=getchar();
	}
	return f*x;
}
int main()
{
	n=read();
	For(i,1,n)
	{
		a[i].x=read();
		a[i].y=read();
	}
	For(i,1,n-1)
	{
		For(j,i+1,n)
		{
			if(abs(a[j].y-a[i].y)<=abs(a[j].x-a[i].x))
				ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define yes cout <<"YES"<<endl
#define no cout <<"NO"<<endl
#define sortv(a) sort(a.begin(), a.end())
typedef vector <long long> vi;
typedef string str;
typedef vector <pair<long long, long long>> vip;
typedef pair <int, int> pi;
typedef set <int> si;
typedef vector <double> vd;

bool isPrime(ll n)
{
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 or n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i += 6) {
        if (n % i == 0 or n % (i + 2) == 0) return false;
    }
    return true;
}

bool sortbysec(const pair<long long, long long> &a, const pair<long long, long long> &b)
{
    return (a.second > b.second);
}

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

void solve()
{
    ll n;
    cin >>n;
    vi x(n), y(n);
    for (int i = 0; i < n; ++i) {
        cin >>x[i]>>y[i];
    }
    ll cnt = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            double s = (double)(y[j] - y[i]) / (double)(x[j] - x[i]);
            if (s <= 1 and s >= -1) {
                cnt++;
            }
        }
    }
    cout <<cnt<<endl;
}

int main()
{
    solve();
}


#include<iostream>
#include<iomanip>
#include<bitset>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
#include<map>
#include<set>
using namespace std;
using ll=long long;

int main(){
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    if(r1 == r2 && c1 == c2){
        cout << 0 << endl;
        return 0;
    }
    if(r1 - c1 == r2 -c2 || r1 + c1 == r2 + c2 || abs(r1 - r2) + abs(c1 - c2) <= 3){
        cout << 1 << endl;
        return 0;
    }
    if((abs(r1 - r2) + abs(c1 - c2)) % 2 == 0){
        cout << 2 << endl;
        return 0;
    }
    for(int i = -2; i <= 2; i++){
        for(int j = -2; j <= 2; j++){
            int r, c;
            r = r1 + i;
            c = c1 + j;
            if(r - c == r2 - c2 || r + c == r2 + c2 || abs(r - r2) + abs(c - c2) <= 3){
                cout << 2 << endl;
                return 0;
            }
        }
    }
    vector<int> x = {3, 0, -3, 0}, y = {0, 3, 0, -3};
    for(int i = 0; i < 4; i++){
        int r, c;
        r = r1 + x[i];
        c = c1 + y[i];
        if(r - c == r2 - c2 || r + c == r2 + c2 || abs(r - r2) + abs(c - c2) <= 3){
            cout << 2 << endl;
            return 0;
        }
    }
    cout << 3 << endl;
    return 0;
}

#include <bits/stdc++.h>
#define fi first
#define se second
#define o2(x) (x) * (x)
#define mk make_pair
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset((a), (b), sizeof((a)))
#define rep(i, s, t) for(register int i = (s), LIM=(t); i < LIM; ++i)
#define per(i, s, t) for(register int i = (s), LIM=(t); i >= LIM; --i)
#define GKD std::ios::sync_with_stdio(false);cin.tie(0)
#define my_unique(x) sort(all(x)), x.erase(unique(all(x)), x.end())
using namespace std;
typedef long long LL;
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
// mt19937 rng(time(NULL));//std::clock()
// mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
// shuffle(arr, arr + n, rng64);
inline int64 read() {
    int64 x = 0;int las = 0;char ch = getchar();
    while (ch < '0' || ch > '9') las |= (ch == '-'), ch = getchar();
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch =
    getchar(); return x = las ? -x : x;
}
inline void write(int64 x, bool las = true) {
    if (x == 0) {putchar('0'); if(las)putchar('\n');else putchar(' ');return;}
    if (x < 0) {putchar('-');x = -x;}
    static char s[23];
    int l = 0;
    while (x != 0)s[l++] = x % 10 + 48, x /= 10;
    while (l)putchar(s[--l]);
    if(las)putchar('\n');else putchar(' ');
}
int lowbit(int x) { return x & (-x); }
template <class T>
T big(const T &a1, const T &a2) {return a1 > a2 ? a1 : a2;}
template <class T>
T sml(const T &a1, const T &a2) {return a1 < a2 ? a1 : a2;}
template <typename T, typename... R>
T big(const T &las, const R &... r) {return big(las, big(r...));}
template <typename T, typename... R>
T sml(const T &las, const R &... r) {return sml(las, sml(r...));}
void debug_out() { cout << '\n'; }
template <typename T, typename... R>
void debug_out(const T &las, const R &... r) {
    cout << las << " ";
    debug_out(r...);
}
#ifdef LH_LOCAL
#define debug(...) cout << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__);
#else
#define debug(...) ;
#endif
/*================Header Template==============*/
const int mod = 998244353;// 998244353
const int INF = 0x3f3f3f3f;
int ksm(int a, int64 b, int kmod = mod) {int res = 1;for(;b > 0;b >>= 1, a = (int64)a * a % kmod) if(b &1) res = (int64)res * a % kmod;return res;}
const int MXN = 2e5 + 5;

int n, m;
class node{
	public:
	int a, b;
	void Rd() {
		a = read(), b = read();
	}
};
node A, B;
int ans;
int is(node A, node B) {
	if(A.a + A.b == B.a + B.b) return 1;
	if(A.a - A.b == B.a - B.b) return 2;
	if(abs(A.a - B.a) + abs(A.b - B.b) <= 3) return 3;
	return 0;
}
void work() {
	A.Rd(), B.Rd();
	if(A.a == B.a && A.b == B.b) ans == 0;
	else if(is(A, B)) ans = 1;
	else {
		node C = A;
		int64 cha = A.b - A.a;
		int64 he = B.a + B.b;
		A.a = (he - cha) / 2;
		A.b = A.a + cha;
		if(is(A, B)) ans = 2;
		else ans = 3;
		A = C;
		cha = B.b - B.a;
		he = A.a + A.b;
		A.a = (he - cha) / 2;
		A.b = he - A.a;
		if(is(A, B)) ans = 2;
		else ans = min(ans, 3);
	}
	printf("%d\n", ans);
}
int main() {
#ifdef LH_LOCAL
    freopen("D:/ACM/mtxt/in.txt", "r", stdin);
    // freopen("D:/ACM/mtxt/out.txt", "w", stdout);
#endif
    for(int cas = 1, tim = 1; cas <= tim; ++ cas) {
        work();
    }
#ifdef LH_LOCAL
    cout << "time cost:" << 1.0 * clock() / CLOCKS_PER_SEC << "s" << endl;
#endif
    return 0;
}


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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "YES" : "NO")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

const int siz = 1e2 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "1";

char a[siz][siz];

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

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    int n, m;
    cin >> n >> m;

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (a[i][j] == '.') {
                if (j + 1 <= m && a[i][j + 1] == '.') {
                    ans++;
                }

                if (i + 1 <= n && a[i + 1][j] == '.') {
                    ans++;
                }
            }
        }
    }

    cout << ans << "\n";

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}

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

#define int             long long
#define ld              long double
#define F               first
#define S               second
#define PB              push_back
#define forn(i,a,b)     for(i=a;i<=b;i++)
#define nfor(i,a,b)     for(i=a;i>=b;i--)
#define all(x)          x.begin(),x.end()
#define rall(x)         x.rbegin(),x.rend()
#define pii             pair<int,int>
#define vi              vector<int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define si              set<int>
#define spii            set<pii>
#define usi             unordered_set<int>
#define uspii           unordered_set<pii>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int>>
#define setbits(x)      __builtin_popcountll(x)
#define tzbits(x)       __builtin_ctzll(x)
#define lzbits(x)       __builtin_clzll(x)
#define pbits(x)        __builtin_parityll(x)
#define gcd             __gcd
#define lcm(x, y)       ((x)*(y))/gcd(x,y)
#define endl            '\n'
#define sz(s)           (int)s.size()
#define sp(x,y)         fixed<<setprecision(y)<<x
const int mod = 1000000007;
const int inf = 1000000000000000000;
const ld PI = 3.1415926535897932384626;
const ld eps = 1e-12;
void __print(int32_t x) {cout<<x;}
void __print(int x) {cout<<x;}
void __print(double x) {cout<<x;}
void __print(ld x) {cout<<x;}
void __print(float x) {cout<<x;}
void __print(bool x) {cout<<(x?"true":"false");}
void __print(char x) {cout <<'\''<<x<<'\'';}
void __print(const char *x) {cout <<'\"' <<x<<'\"';}
void __print(const string &x) {cout<<'\"'<<x<<'\"';}
template<typename T,typename V>     void __print(const pair<T,V> &x) {cout<<'{';__print(x.first);cout<<',';__print(x.second);cout<<'}';}
template<typename T>                void __print(const T &x) {int f=0;cout<<'{';for(auto &i:x)cout<<(f++?",":""),__print(i);cout<<"}";}void _print(){cout<<"]\n";}
template <typename T,typename... V> void _print(T t, V... v) {__print(t);if(sizeof...(v))cout<<", ";_print(v...);}
#define dbg(x...) cout<<"["<<#x<<"]=[";_print(x)
int powerm(int base,int exp) {int res=1;base%=mod;while(exp>0){if(exp&1)res=(res*base)%mod;base=(base*base)%mod;exp=exp>>1;}return res;}
int power(int base,int exp) {int res=1;while(exp>0){if(exp&1)res=res*base;base=base*base;exp=exp>>1;}return res;}
float powerNeg(float base,int exp) {float temp;if(exp==0)return 1;temp=powerNeg(base,exp/2);if(exp%2==0)return temp*temp;else{if(exp>0)return base*temp*temp;else return (temp*temp)/base;}}
int modinv(int exp) {return powerm(exp,mod-2);}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

const int N=2e6+5;

void solve()
{
    int i,j;
    int n,m; cin>>n>>m;
    vector<vector<char>> a(n,vector<char>(m));
    forn(i,0,n-1) forn(j,0,m-1) cin>>a[i][j];

    int cnt=0;
    forn(i,0,n-1){
        forn(j,0,m-2){
            if(a[i][j]=='.' and a[i][j+1]=='.') cnt++;
        }
    }
    forn(j,0,m-1){
        forn(i,0,n-2){
            if(a[i][j]=='.' and a[i+1][j]=='.') cnt++;
        }
    }

    cout<<cnt<<endl;
}

int32_t main()
{

    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t,T=1;
    // cin>>T;
    forn(t,1,T)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    // cout<<endl<<"Times Elapsed:"<<1.0*clock()/CLOCKS_PER_SEC<<"sec";
    return 0;
}


#include<bits/stdc++.h>
//#include <boost/math/common_factor.hpp>
using namespace std;

/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loop1(i,a,b) for(int i=a;i<=b;i++)
#define rloop(i,a,b) for(int i=a;i>b;i--)
#define rloop1(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
//#define mp make_pair
#define pii pair<ll,ll>
#define int   long long int
#define double long double
#define min_heap priority_queue <int, vector<int>, greater<int> >
#define ff first
#define ss second
#define ncr(n,r) fact[n]*modInv(fact[r])*modInv(fact[n-r])
#define MOD 1000000007
//#define MOD 998244353
#define inf 1e18
//#define modInv(a) binExp(a,mod-2)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test int t;cin>>t;while(t--)
#define nl "\n"
#define ceill(a,b) ((a)/(b))+(((a)%(b))!=0)
//-------------------------IMPORTANT FUNCTIONS START---------------------
int powr(int x,  int y)
{
    int res = 1;

    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

ll power(ll a, ll b, ll mod){
    ll x = 1LL, y = a;
    while (b > 0LL){
        if (b%2LL){
            x = (x*y);
            if(x>mod) x%=mod;
        }
        y = (y*y);
        if(y>mod) y%=mod;
        b /= 2LL;
    }
    return x;
}
ll mod_inv(ll n, ll mod){
    return power(n, mod-2LL, mod);
}

bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i <=sqrt(n); i++)
        if (n % i == 0)
            return false;

    return true;
}

int lcm(int a, int b)
{
    return (a / __gcd(a, b)) * b;
}
//-------------------------IMPORTANT FUNCTIONS END---------------------
 // initialize 2d vector   vector<vector<int>> dp(n+1,vector<int>(x+1,0));
// 1/n+2/n+3/n.....n/n=O(logn)
// never use sqrt*sqrt cf compiler chodu hai
// negative value m floor or ceil ulte kam karte equation solve karte waqt dhyan rakh4
// order of 1e8 int 1 sec is ok

void solve(){
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   int x = d*c -b;
   if(x<=0)cout<<"-1";
   else cout<<ceill(a,x);
}

signed  main()
{
 fast
  //cout<<fixed<<setprecision(13);
  //test
    solve();

}

#include<cstdio>
#include<algorithm>
#define int long long
const int Q=100005;
const int INF=(1<<30);
using namespace std;
typedef long long ll;
#define rg register int
char buf[1<<21],*p1=buf,*p2=buf;
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline bool ig(char c){return c>=48&&c<=57;}
inline void read(int &oi){char c;int f=1,res=0;while(c=gc(),(!ig(c))&&c^'-');c^'-'?res=(c^48):f=-1;while(c=gc(),ig(c))res=res*10+(c^48);oi=f*res;}
inline void print(int oi){if(oi<0)putchar('-'),oi=~oi+1;if(oi>9)print(oi/10);putchar(oi%10+48);}
inline void write(int oi,char c){print(oi);putchar(c);}
int a,b,c,d,res;
signed main(){
	read(a);read(b);read(c);read(d);
	c*=d;c-=b;if(c>0)res=(a-1)/c+1;else res=-1;write(res,'\n');
	return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define sqr(x) ((x) * (x))
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 3e3 + 10;
const LL INF = 1e9 + 10;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    string s;
    cin>>s;
    deque<char> dq;
    int f = 0;

    for(char ch : s)
    {
        if(ch == 'R') f ^= 1;
        else if(f == 0)
        {
            if(dq.size() && dq.back() == ch) dq.pop_back();
            else dq.push_back(ch);
        }
        else
        {
            if(dq.size() && dq.front() == ch) dq.pop_front();
            else dq.push_front(ch);
        }
    }

    if(f == 0)
    {
        while(!dq.empty())
        {
            char ch = dq.front();
            dq.pop_front();
            cout<<ch;
        }
    }
    else
    {
        while(!dq.empty())
        {
            char ch = dq.back();
            dq.pop_back();
            cout<<ch;
        }
    }

    cout<<'\n';

    return 0;
}

#include "bits/stdc++.h"

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(x) cerr << #x << " == " << (x) << '\n';
#define all(X) begin(X), end(X)
#define size(X) (int)std::size(X)

using ll = long long;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

void fail()
{
    cout << -1 << endl;
    exit(0);
}

template<int n>
bitset<n> read_bitset()
{
    string str; cin >> str;
    reverse(all(str));
    return bitset<n>(str);
}

int main()
{ _
    constexpr int nmax = 5e5;

    int n; cin >> n;

    bitset<nmax> s = read_bitset<nmax>(), t = read_bitset<nmax>();

    for (int i = 1; i < n; ++i)
    {
        s[i] = s[i] ^ s[i - 1];
        t[i] = t[i] ^ t[i - 1];
    }

    ll ans = 0;

    for (int i = 0, j = 0; i < n; ++i, j = max(j, i))
    {
        if (s[j] == t[i]) continue;

        while (j < n && s[j] != t[i]) s[j++] = t[i];

        if (j == n) fail();

        ans += j - i;
    }

    cout << ans << endl;

    exit(0);
}


#include <bits/stdc++.h>
using namespace std;
class factor{
    int size;
    vector<int> primes;
    vector<int> lp;
public:
    explicit factor(int n): size(n){
        lp.assign(n+1,-1);
        for(int i=2;i<=n;i++){
            if(lp[i]==-1){
                primes.push_back(i);
                lp[i]=i;
            }
            for(int j=0;primes[j]<=lp[i]&&primes[j]*i<=n&&j<static_cast<int>(primes.size());j++){
                lp[primes[j]*i]=primes[j];
            }
        }
    }
    vector<pair<int,int> > get(int n){
        vector<pair<int,int> > ans;
        while(n>1){
            int p=lp[n];
            int cnt=0;
            while(n%p==0){
                cnt++;
                n/=p;
            }
            ans.emplace_back(p,cnt);
        }
        return ans;
    }
    long long numdivisors(int n){
        long long ans=1LL;
        while(n>1){
            int p=lp[n];
            int cnt=0;
            while(n%p==0){
                cnt++;
                n/=p;
            }
            ans*=cnt+1;
        }
        return ans;
    }
};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int k;
    cin>>k;
    factor Taha(2*100000+1);
    long long ans=0LL;
    for(int div=1;div<=k;div++){
        ans+=Taha.numdivisors(div)*(k/div);
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define deb(x) cout << #x << " " << x << endl;
#define mod 1000000007
#define fast std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define endl "\n"

const ll INF = 1e18;
const ll NEGINF = -1 * INF;

/*NOTES: Take care of ll vs int
         Never use an iterator after erasing it
*/

const int N = 20;

ll dp[1 << N];
vector<array<int, 2>> arr[N];
int n, m;

ll build(int mask)
{
    if (mask == 0)
    {
        return 1;
    }
    if (dp[mask] != -1)
    {
        return dp[mask];
    }
    int currBits = __builtin_popcountll(mask);
    vector<int> a(n + 1, 0);
    for (int i = 0; i < n; i++)
    {
        if (mask & (1 << i))
        {
            a[i + 1]++;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        a[i] += a[i - 1];
    }
    for (auto it : arr[currBits])
    {
        if (a[it[0]] > it[1])
        {
            return dp[mask] = 0;
        }
    }
    ll ways = 0;
    for (int i = 0; i < n; i++)
    {
        if (mask & (1 << i))
        {
            ways += build(mask ^ (1 << i));
        }
    }
    return dp[mask] = ways;
}

// out of the first 'x' elements, at most 'z' elements should be <= 'y'
void solve()
{
    cin >> n >> m;
    int x, y, z;
    for (int i = 0; i < m; i++)
    {
        cin >> x >> y >> z;
        arr[x].push_back({y, z});
    }
    memset(dp, -1, sizeof(dp));
    cout << build((1 << n) - 1) << endl;
}

int main()
{
    fast;
#ifndef ONLINE_JUDGE
    freopen("/home/kalit/Desktop/Data Structures-Algo-Competitive/src/codeforces/input.txt", "r", stdin);
    freopen("/home/kalit/Desktop/Data Structures-Algo-Competitive/src/codeforces/output.txt", "w", stdout);
#endif
    int T = 1;
    while (T--)
    {
        solve();
    }
    //cout<< "Done in " << clock() / CLOCKS_PER_SEC <<"sec"<< endl;
    return 0;
}

#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace std;

#pragma GCC optimize("O3","unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("avx2")

using namespace __gnu_pbds;
template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k) -> iterator of kth element (in sorted fashion : low - high)
// order_of_key(x) -> #numbers strictly less than x

#define sync ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) x.begin(),x.end()
#define unq(a) sort(all(a));a.resize(unique(all(a)) - a.begin())
#define fi first
#define se second
//#define endl '\n'

using pii = pair<int , int>;
using ll = long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//mt19937 rng(0);

// const int N = 3e6 + 5;
// vector<ll> f(N);

// void u(int x, int way){
//   for (int i = x; i < N; i += (i & -i)){
//     f[i] += way;
//   }
// }

// ll gt(int x){
//   ll r = 0;
//   for (int i = x; i > 0; i -= (i & -i)){
//     r += f[i];
//   }
//   return r;
// }

int main(){

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

    sync

    int t = 1;
    //cin >> t;
    while(t--){
      int n;
      ll k, gn = 0;
      cin >> n >> k;
      int smblk = -1;

      vector<ll> way2(2 * n + 1);
      int l = 2, r = 2 * n, cnt = 0;
      while(l <= r){
        way2[l] = way2[r] = ++cnt;
        l++; r--;
      }
      vector<ll> df(3 * n + 5);
      for (int i = 1; i <= 2 * n; i++){
        df[i + 1] += way2[i];
        df[i + n + 1] -=  way2[i];
      }
      for (int i = 1; i <= 3 * n; i++){
        df[i] += df[i - 1];
      }
      for (ll sm = 3; sm <= 3 * n; sm++){
        if (gn + df[sm] < k){
          gn += df[sm];
        }
        else{
          smblk = sm;
          break;
        }
      }
      assert(smblk != -1);
      int bu = -1, ts = -1;
      for (int b = 1; b <= n; b++){
        if (smblk - b < 0 or smblk - b > 2 * n) continue;
        if (gn + way2[smblk - b] < k){
          gn += way2[smblk - b];
        }
        else{
          bu = b;
          break;
        }
      }
      assert(bu != -1);
      //cout << smblk << " " << bu << endl << flush;
      for (int tz = 1; tz <= n; tz++){
        if (smblk - bu - tz < 0 or smblk - bu - tz > n) continue;
        gn++;
        //cout << tz << " " << gn << " " << k << endl << flush;
        if (gn == k){
          ts = tz;
          break;
        }
      }
      assert(ts >= 1 && ts <= n);
      cout << bu << " " << ts << " " << smblk - bu - ts << endl;
    }
    cerr << "processor time: " << clock() / (double) CLOCKS_PER_SEC << "s    ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) v.begin(), v.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;}

int main() {
    ll N, Q; cin >> N >> Q;
    vector<ll> A(N); rep(i, N) cin >> A[i];
    vector<ll> sen(100000, 0);
    for (int i = 0; i < N; ++i) {
        sen[i/1000] ^= A[i];
    }

    for (int q = 0; q < Q; ++q) {
        ll t, x, y;
        cin >> t >> x >> y;
        --x; --y;
        if (t == 1) {
            A[x] ^= (y+1);
            sen[x/1000] ^= (y+1);
        }
        else if (t == 2 && y - x > 2100) {
            ll res = 0;

            ll num = x;
            while (num%1000 != 0) {
                res ^= A[num];
                ++num;
            }

            for (int i = (x+999)/1000; i < y/1000; ++i) {
                res ^= sen[i];
            }

            ll tmp = (y/1000) * 1000;
            while (tmp != y+1) {
                res ^= A[tmp];
                ++tmp;
            }

            cout << res << endl;
        }
        else {
            ll res = 0;
            for (int i = x; i <= y; ++i) {
                res ^= A[i];
            }
            cout << res << endl;
        }
    }
}

// Problem: F - Range Xor Query
// Contest: AtCoder - AtCoder Beginner Contest 185
// URL: https://atcoder.jp/contests/abc185/tasks/abc185_f
// Memory Limit: 1024 MB
// Time Limit: 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define int         long long int
#define vi           vector<int>
#define pii          pair<int,int>
#define vpp          vector<pii>
#define mii          map<int,int>
#define pb           push_back
#define rep(i,a,bb)  for(int i=a;i<bb;i++)
#define ff           first
#define ss           second
#define fast         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test         int T;cin>>T;while(T--)
#define __sort(v)    sort(v.begin(),v.end())
#define __rsort(v)   sort(v.rbegin(),v.rend())
#define setbits(x)   __builtin_popcount(x)
#define zrobits(x)   __builtin_ctzint(x)
#define endl '\n'
#define debug(x)  cerr<<"[ "<<#x<<" : "<<x<<" ]"<<endl
#define debugp(x) cerr<<"[ "<<#x<<".ff : "<<x.first<<", "<<#x<<".ss : "<<x.second<<" ]"<<endl
#define debugs(x) cerr<<"[ "; for(auto i:x) cerr<<i<<" "; cerr<<" ]"<<endl;
#define debugm(x) cerr<<"----------"<<endl; for(auto i:x) cerr<<i.ff<<":"<<i.ss<<endl; cerr<<"----------";
#define PI 3.14159265359
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int dxk[]={0,0,1,-1,1,1,-1,-1};
int dyk[]={1,-1,0,0,1,-1,1,-1};
const int inf = 1e+18;
const int mod = 1e+9 + 7;
int cases = 1;

int power(int x, int p, int m){
	int res = 1;
	while(p){
		if(p&1)
		  res=(res*x)%m;
		x = (x*x)%m;
		p/=2;
	}
	return res;
}

int inverse_mod(int x, int p, int m){
	// Fermat's little theorem
	// a^p = a  % p
	// a^(p-1) = a % p
	// a^(p-2) = (1/a)%p => inverse modulo
	return power(x, p-2, m);
}

const int mxN = 1200005;
int tree[mxN];

void update(int v){
	tree[v] = tree[2*v] ^ tree[2*v+1];
}

int combine(int l, int r){

    return l^r;
}

void build(int v, int tl, int tr, int* a){
	if(tl>tr)
	   return;
	if(tl==tr){
		tree[v] = a[tl];
		return;
	}
	int mid = (tl+tr)/2;
	build(2*v, tl, mid, a);
	build(2*v+1, mid+1, tr, a);
	update(v);

}

void modify(int v, int tl, int tr, int pos, int val){
	if(tl>tr)
	   return;
	if(tl==tr){
		tree[v] = tree[v] ^ val;
		return;
	}
	int mid = (tl+tr)/2;
	if(pos<=mid)
	   modify(2*v, tl, mid, pos, val);
	else
	   modify(2*v+1, mid+1, tr, pos, val);
	update(v);

}
int mrs(int v, int tl, int tr, int ql, int qr){
	if(tl>qr||tr<ql)
	{
		return 0;
	}
	if(tl>=ql&&tr<=qr){
		return tree[v];
	}
	int mid = (tl+tr)/2;
     return mrs(2*v, tl, mid, ql, qr)^mrs(2*v+1, mid+1, tr, ql, qr);
}

void solve()
{
	int n, q;
	cin>>n>>q;

	int a[n];

	rep(i,0,n)
	  cin>>a[i];

	build(1, 0, n-1, a);

	rep(i,0,q)
	{
		int x, y, z;
		cin>>x>>y>>z;

		if(x==1)
		{
			modify(1, 0, n-1, y-1, z);
		}
		else
		{
			cout<<mrs(1,0,n-1,y-1,z-1)<<endl;
		}
	}

}

int32_t main()
{
  fast;
  //test{
 // cout<<"Case #"<<cases<<": ";
  solve();
  //++cases;
  //}
  return 0;
}