#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#include<random>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (int)(Y);++(X))
#define reps(X,S,Y) for (int (X) = (int)(S);(X) < (int)(Y);++(X))
#define rrep(X,Y) for (int (X) = (int)(Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (int)(Y)-1;(X) >= (int)(S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"
#define cauto const auto

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
template<class A,class B> pair<A,B> operator+(const pair<A,B> &p,const pair<A,B> &q){ return {p.X+q.X,p.Y+q.Y};}
template<class A,class B,class C,class D> pair<A,B>& operator+=(pair<A,B> &p,const pair<C,D> &q){ p.X+=q.X; p.Y+=q.Y; return p;}
template<class A,class B> pair<A,B> operator-(const pair<A,B> &p,const pair<A,B> &q){ return {p.X-q.X,p.Y-q.Y};}
template<class A,class B,class C,class D> pair<A,B>& operator-=(pair<A,B> &p,const pair<C,D> &q){ p.X-=q.X; p.Y-=q.Y; return p;}
template<class A,class B> istream& operator>>(istream &is, pair<A,B> &p){ is>>p.X>>p.Y; return is;}
template<class T=ll> T read(){ T re; cin>>re; return move(re);}
template<class T=ll> T read(const T &dec){ T re; cin>>re; return re-dec;}
template<class T=ll> vector<T> readV(const int sz){ vector<T> re(sz); for(auto &x:re) x=read<T>(); return move(re);}
template<class T=ll> vector<T> readV(const int sz, const T &dec){ vector<T> re(sz); for(auto &x:re) x=read<T>(dec); return move(re);}
vv<int> readG(const int &n,const int &m){ vv<int> g(n); rep(_,m){ cauto a=read<int>(1),b=read<int>(1); g[a].pb(b); g[b].pb(a);} return move(g);}
vv<int> readG(const int &n){ return readG(n,n-1);}
const ll MOD=1e9+7; //998244353

struct RMQ{
  const int INF=MOD;
  vv<int> mn;
  int D;
  void upd(const vector<int> &v){
    mn.clear();
    D=0;
    for(int i=v.size();i;i/=2) ++D;
    mn.resize(D+1,vector<int>(1<<D+1,INF));
    rep(i,v.size()) mn[D][i]=v[i];
    rrep(i,D)rep(j,1<<D){
      int b=(j>>(D-i)|1)<<(D-i);
      //assert(b!=(1<<D) || !(j>>(D-i)&1));
      mn[i][j]=j>>(D-i)&1?get(b,j+1):get(j,b);
    }
  }
  RMQ(){}
  RMQ(const vector<int> &v){upd(v);}
  int get(int l,int r){ //[l,r)
    --r;
    if(l==r)return mn[D][l];
    if(l>r) return INF;
    int d=__builtin_clz(l^r)+D-31;
    return min(mn[d][l],mn[d][r]);
  }
};

// Larsson-Sadakane's Suffix array Construction: O(n (log n)^2)
struct SA:public vector<int>{
  struct SAComp {
    const int h;
    const vector<int> &g;
    SAComp(int h, const vector<int> &g) : h(h), g(g) {}
    bool operator() (int a, int b) {
      return a == b ? false : g[a] != g[b] ? g[a] < g[b] : g[a+h] < g[b+h];
    }
  };
  vector<int> inv,lcp;
  string str;
  RMQ rmq;
  SA(){}
  SA(const string &str):str(str){build(str);}
  void build(const string &s){
    str=s;
    buildSA();
    buildLCP();
    rmq.upd(lcp);
    inv.resize(size());
    rep(i,size()) inv[at(i)]=i;
  }
  void buildSA(){
    int n=str.size();
    vector<int> g(n+1),b(n+1);
    resize(n+1);
    rep(i,n+1) at(i)=i, g[i]=str[i];
    
    sort(all(*this), SAComp(0,g));
    for(int h=1; b[n]!=n; h*=2) {
      SAComp comp(h,g);
      sort(all(*this),comp);
      rep(i,n) b[i+1]=b[i]+comp(at(i),at(i+1));
      rep(i,n+1) g[at(i)]=b[i];
    }
  }
  void buildLCP(){
    int n=str.size();
    int h=0;
    vector<int> b(n+1);
    lcp.resize(n+1);
    rep(i,n+1) b[at(i)]=i;
    rep(i,n+1) {
      if(b[i]){
	for (int j=at(b[i]-1); j+h<n && i+h<n && str[j+h]==str[i+h]; ++h);
	lcp[b[i]]=h;
      } else lcp[b[i]]=-1;
      if (h>0) --h;
    }
  }
  
  int getMn(int l,int r){return rmq.get(l+1,r+1);}
};
ostream& operator<<(ostream &os,const SA &sa){
  rep(i,sa.size()) os<<sa.lcp[i]<<"\t"<<sa.str.substr(sa[i])<<endl;
  return os;
}

#include <atcoder/all>
using namespace atcoder;
#ifdef NUIP
#include "atcoder/output"
#endif

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	cauto s=read<string>();
	// SA sa(s);
	// out(sa,1);
	cauto sa=suffix_array(s);
	cauto lcp=lcp_array(s,sa);
	out(sa,lcp,1);
	ll re=s.size()-sa[0];
	rep(i,lcp.size()){
		out(i,s.size()-sa[i+1]-lcp[i],1);
		re+=s.size()-sa[i+1]-lcp[i];
	}
	cout<<re NL;
  return 0;
}


Measured memory_bytes: 15632