#define ll long long
#define lld double
#define M 202
#define f first
#define s second
#define pi 3.141592653589793238
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define N 100002
#define Endl endl
#define maxx(a,b,c,d) max(max(a,b),max(d,c))
#define minn(a,b,c,d) min(min(a,b),min(d,c))
#define pb push_back
#define mod 1000000007  
#define pp 31
#define ss(v) sort(v.begin(),v.end())
#define sr(v) sort(v.begin(),v.end(),greater<pll>())
#define rin(A, B, C) (((A)<=(B))&&((B)<=(C)))
#include <bits/stdc++.h>
using namespace std;
ll power(ll a, ll b)
{
	if(!b)return 1LL;
	ll aa=power(a,b/2);
	if(b%2)return aa*aa%mod*a%mod;
	return aa*aa%mod;
}
ll im(ll a)
{
	return power(a,mod-2);
}
// ll ncr(ll n,ll r)
// {
// 	return f[n]*im(f[r])%mod*im(f[n-r])%mod;
// }
bool check(ll n)
{
	ll m=n;
	while(n)
	{
		if(n%10!=0 && m%(n%10)!=0)
		{
			return false;
		}
		n/=10;
	}
	return true;
}
pll ol(ll a, ll b, ll c, ll d)
{
	a=max(a,c);
	b=min(b,d);
	return {a,b};
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// freopen("output.txt", "w", stdout);
	// freopen("input.txt", "r", stdin);
    ll a,b;
	cin>>a>>b;
	ll ans1=0,ans2=0;
	while(a)
	{
		ans1+=a%10;
		a/=10;
	}
	while(b)
	{
		ans2+=b%10;
		b/=10;
	}
	cout<<max(ans1,ans2)<<endl;

	return 0;
}

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#define M 100001
typedef long long ll;
typedef unsigned long long ull;

inline void read(ull &T) {
	ull x = 0; bool f = 0; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') f = !f; c = getchar(); }
	while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	T = f ? -x : x;
}

ull n, l, r;

ull s(ull x) { return (1 + x) * x / 2; }

int main() {
    read(n);
    l = 1, r = 6e9;
    while (l <= r) {
        ull mid = (l + r) >> 1;
        if (s(mid) > n + 1) r = mid - 1;
        else l = mid + 1;
    }
    std::cout << n - r + 1 << '\n';
    return 0;
}