#include <bits/stdc++.h>

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)


using namespace std;
//using namespace __gnu_pbds;

typedef long long  ll;
typedef vector<int> vi;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define initseg ll new_nodo=(pnodo*2),mid=(iz+der)/2;
#define fi first
#define se second
#define ptr item*


const long long INF = 1e18;
const ll tam =1000100;
const ll MOD=998244353;
const ll cmplog=29;

int main()
{
    ll n;
    cin>>n;
    ll iz=1,der=2;
    ll mid;
    while(der*(der+1)/2<=n+1)
        der*=2;

    while(iz+1<der)
    {
        mid=(iz+der)/2;
        if (mid*(mid+1)/2<=n+1)
            iz=mid;
        else der=mid;
    }
    cout<<n-iz+1<<endl;
}

// #include<bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cassert>
#include <bitset>

using namespace std;

int main() {
  long long int N, ans=0;
  long long int x;
  string y;
  

  
  cin >> N;


  for(size_t i=1; i<1e+6; i++){
    y = to_string(i);
    y += to_string(i);
    x = stoll(y);
    
    if(x > N){
      break;
    }
    else{
      ans += 1;
    }
  }

  cout << ans << endl;
} 
