/*Author : Siriuslight | Subham Pal
           Army Institute of Technology
*/
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define sd(x) scanf("%d", &x);
#define sld(x) scanf("%lld", &x);
using namespace std;    typedef long long ll;    typedef long double ld;
const ll inf = 1e9, N = 1e5+5;
const ll INF = 1e18, MOD = 1e9+7;
ll powmod(ll a,ll b,ll m=MOD){ll r=1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}
ll power(ll a,ll b){ll r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
ll gcd(ll a,ll b){if(b>a)swap(a,b);if(!b)return a;return gcd(b,a%b);}

int ans(0);

bool palin(vector<int> v){
    for(int i = 0; i < v.size() / 2; ++i)
        if(v[i] != v[v.size() - 1 - i])
            return 0;
    return 1;
}

vector <int> add(vector <int> v1){
    vector <int> v2, res;
    v2 = v1;
    reverse(v2.begin(), v2.end());
    int carry(0);
    for(int i = v1.size() - 1; i >= 0; --i){
        int t = v1[i] + v2[i] + carry;
        res.push_back(t % 10);
        carry = t / 10;
    }
    while(carry){
        res.push_back(carry % 10);
        carry /= 10;
    }
    reverse(res.begin(), res.end());
    return res;
}

bool lychrel(int x){
    vector <int> v;
    while(x){
        v.push_back(x % 10);
        x /= 10;
    }
    reverse(v.begin(), v.end());
    for(int i = 0; i <= 50; ++i){
        if(palin(v)){
            return 0;
        }
        v = add(v);
    }
    return 1;
}

int main(){
    FIO;
    cout << setprecision(10) << fixed;

    for(int i = 1; i < 1e4; ++i){
        ans += lychrel(i);
    }
    cout << ans;
    return 0;
}