#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int INF = 1e9;
const ll LINF = 1e18;
struct BigInt {
static const int BASE = 1e9;
static const int B = 9;
vector<int> a;
BigInt() {}
BigInt(ll x) {
for (; x > 0; x /= BASE) {
a.push_back(x % BASE);
}
}
BigInt(const string &s) {
for (int i = (int)s.size() - 1; i >= 0; i -= B) {
int beg = max(0, i - B + 1);
int len = i - beg + 1;
int block = stoi(s.substr(beg, len));
a.push_back(block);
}
trim();
}
void trim() {
while (!a.empty() && a.back() == 0) {
a.pop_back();
}
}
bool isZero() {
return (a.empty());
}
BigInt operator+=(const BigInt &other) {
int n = a.size(), m = other.a.size();
int carry = 0;
for (int i = 0; i < max(n, m) || carry; i++) {
if (i == a.size()) {
a.push_back(0);
}
a[i] += (i < m ? other.a[i] : 0) + carry;
carry = (a[i] >= BASE);
if (carry) a[i] -= BASE;
}
return *this;
}
BigInt operator*=(int b) {
int n = a.size();
int carry = 0;
for (int i = 0; i < n || carry; i++) {
if (i == a.size()) {
a.push_back(0);
}
ll cur = 1ll * a[i] * b + carry;
a[i] = cur % BASE;
carry = cur / BASE;
}
trim();
return *this;
}
BigInt operator+(const BigInt &other) const {
return BigInt(*this) += other;
}
BigInt operator*(int b) const {
return BigInt(*this) *= b;
}
friend istream& operator>>(istream &in, BigInt &num) {
string s;
in >> s;
num = BigInt(s);
return in;
}
friend ostream& operator<<(ostream &out, const BigInt &num) {
out << (num.a.empty() ? 0 : num.a.back());
for (int i = (int)num.a.size() - 2; i >= 0; i--) {
out << setw(B) << setfill('0') << num.a[i];
}
return out;
}
};
vector<int> digit;
vector<int> getDigit(const string& s) {
vector<int> ans;
for (int i = 0; i < s.size(); i++) {
ans.push_back(s[i] - '0');
}
reverse(ans.begin(), ans.end());
return ans;
}
// dp = {tổng các chữ số, số lượng số}
bool vis[101][2];
pair<BigInt, BigInt> memo[101][2];
pair<BigInt, BigInt> dp(int idx, bool smaller) {
if (idx == -1) return {0, 1};
pair<BigInt, BigInt>& ans = memo[idx][smaller];
if (vis[idx][smaller]) return ans;
vis[idx][smaller] = true;
ans = make_pair(0, 0);
int max_digit = (smaller) ? 9 : digit[idx];
for (int i = 0; i <= max_digit; i++) {
pair<BigInt, BigInt> next_ans = dp(idx - 1, smaller | (i < digit[idx]));
ans.first += next_ans.first + next_ans.second * i;
ans.second += next_ans.second;
}
return ans;
}
BigInt solve(const string& s) {
digit = getDigit(s);
memset(vis, 0, sizeof vis);
return dp(digit.size() - 1, 0).first;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
string s;
cin >> s;
BigInt ans = solve(s);
cout << ans << '\n';
}