#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define e "\n"
#define fl(x,n) for(ll i=x;i<=n;i++)
#define fl2(x,n) for(ll i=x;i>=n;i--)
using namespace std;
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        int n,Max,Min,x;
        cin >> n;
        cin >> Max;
        fl(2,n)
        {
            cin >> x;
            if(x>Max)
                Max=x;
        }
        cin >> Min;
        fl(2,n)
        {
            cin >> x;
            if(x<Min)
            Min=x;
        }
        if(Min-Max+1<=0)
            cout << 0 << e;
        else
            cout << Min-Max+1 << e;



       return 0;
}

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define endl "\n"
#define    rep(X,Y)     for(X=0;X<Y;X++)
#define    rep1(X,Y)    for(X=1;X<=Y;X++)
#define    rrep(X,Y)    for(X=Y-1;X>=0;X--)
#define    rrep1(X,Y)   for(X=Y;X>=1;X--)
#define ml ll T,g; cin>>T; for(g=0;g<T;g++)
#define case "Case "<<g+1<<": "
#define sf(T) scanf("%lld",&T)
#define pf(T) printf("%lld\n",T)
#define FastRead                      \
                                    ios_base::sync_with_stdio(false); \
                                    cin.tie(0);
#define pi acos(-1)
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main()
{
    FastRead
    string a;
    cin>>a;
    ll n=a.size(),i,c=0,d=0;
    rep(i,n/2)
    {
        if(a[i]!=a[n-i-1])
        {
            c=1;
            break;
        }

    }
    if(c==0)
        cout<<"Yes";

    else
    {
        rrep(i,n)
        {
            if(a[i]!='0')
            {
                d=i;
                break;
            }

        }
        c=0;
        for(i=0;i<=d;i++)
        {
            if(a[i]!=a[d-i])
            {
                c=1;
                break;
            }
        }
        if(c==0)
            cout<<"Yes";
        else
            cout<<"No";
    }

    return 0;
}
