#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define cbrt cbrtl
using namespace std;
ll n,m,flag;
ll posx=-1,posy=-1;
char a[200][200];
ll visited[200][200],done[200][200];
ll px[]={1,-1,0,0};
ll py[]={0,0,-1,1};
ll isvalid(ll y,ll x)
{
	if(y>=1 && y<=n && x>=1 && x<=m )
	{
		if(done[y][x] && !visited[y][x])
			return 1;
		return 0;
	}
	return 0;
}
ll valid(ll y,ll x)
{
	if(y>=1 && y<=n && x>=1 && x<=m )
	{
		if(a[y][x]!='*' && !visited[y][x])
			return 1;
		return 0;
	}
	return 0;
}
void fin(ll u,ll v)
{
	//cout<<u<<" "<<v<<"\n";
	visited[u][v]=1;
	done[u][v]=1;
	if(u==posy && v==posx)
	{
		flag=1;
		return;
	}
	ll i;
	for(i=0;i<4;i++)
		if(valid(u+py[i],v+px[i]))
		{
			fin(u+py[i],v+px[i]);
			if(flag)
				return;
		}
	done[u][v]=0;
}
void print(ll y,ll x,ll swapl,ll swapu)
{
	ll i;
	visited[y][x]=1;
	if(y==posy && x==posx)
		{
			exit(0);
		}

	for(i=0;i<4;i++)
		if(isvalid(y+py[i],x+px[i]))
		{
			if(px[i]==1)
			{
				if(swapl)
					cout<<"L"<<endl;
				else
					cout<<"R"<<endl;
			}
			else if(px[i]==-1)
			{
				if(swapl)
					cout<<"R"<<endl;
				else
					cout<<"L"<<endl;
			}
			else if(py[i]==1)
			{
				if(swapu)
					cout<<"U"<<endl;
				else
					cout<<"D"<<endl;
			}
			else
			{
				if(swapu)
					cout<<"D"<<endl;
				else
					cout<<"U"<<endl;
			}
			cin>>x>>y;
			print(x,y,swapl,swapu);
		}
}
int main()
{
  IOS
  cin>>n>>m;
  ll i,j,x,y;
  for(i=1;i<=n;i++)
  {
  	string s;
  	cin>>s;
  	for(j=1;j<=m;j++)
  	{
  		a[i][j]=s[j-1];
  		if(a[i][j]=='F')
  		{
  			posy=i;
  			posx=j;
  		}
  	}
  }
  ll cnt=2*n*m;
  if(n==1)
  {
	 	cout<<"R"<<endl;
	 	cin>>x>>y;

	 	if(a[x][y]=='F'||x<0)
	 		return 0;

	 	if(y==1)
	 	{
	 		while(a[x][y]!='F')
	 		{
	 			cout<<"L"<<endl;
	 			cin>>x>>y;
	 			if(x<0)
	 				return 0;
	 		}
	 	}
	 	else
	 	{
	 		while(a[x][y]!='F')
	 		{
	 			cout<<"R"<<endl;
	 			cin>>x>>y;
	 			if(x<0)
	 				return 0;
	 		}
	 	}
  }
  else if(m==1)
  {
	  	cout<<"D"<<endl;
	  	cin>>x>>y;

	 	if(x<0 || a[x][y]=='F')
	 		return 0;
	 	if(y==1)
	 	{
	 		while(a[x][y]!='F')
	 		{
	 			cout<<"U"<<endl;
	 			cin>>x>>y;
	 			if(x<0)
	 				return 0;
	 		}
	 	}
	 	else
	 	{
	 		while(a[x][y]!='F')
	 		{
	 			cout<<"D"<<endl;
	 			cin>>x>>y;
	 			if(x<0)
	 				return 0;
	 		}
	 	}
  }
  else
  {
	  	ll swapl=-1,swapu=-1;
	  	if(a[1][2]!='*')
	  	{
		  		cout<<"R"<<endl;
		  		cin>>x>>y;
		  		if(a[x][y]=='F' || x<0)
		  			return 0;
		  		if(y==1)
		  			swapl=1;
		  		else
		  		{
		  			cout<<"L"<<endl;
		  			cin>>x>>y;
		  			if(a[x][y]=='F')
		  				return 0;
		  			swapl=0;
		  		}
		  		while(a[2][y]=='*')
		  		{
		  			if(swapl)
		  				cout<<"L"<<endl;
		  			else
		  				cout<<"R"<<endl;
		  			cin>>x>>y;
		  			if(x<0 || a[x][y]=='F')
		  				return 0;
		  		}
		  		cout<<"D"<<endl;
		  		cin>>x>>y;
		  		if(x==1)
		  			swapu=1;
		  		else
		  			swapu=0;
		  	//	cout<<"here\n";
		  		flag=0;
		  		memset(visited,0,sizeof(visited));
		  		fin(x,y);
		  	/*	for(i=1;i<=n;i++)
		  		{
		  			for(j=1;j<=m;j++)
		  				cout<<done[i][j]<<" ";
		  			cout<<"\n";
		  		}*/
		  		//cout<<flag<<" "<<posy<<" "<<posx<<"\n";
		  		memset(visited,0,sizeof(visited));
		  		print(x,y,swapl,swapu);
	  	}
  	else
  	{
	  		cout<<"D"<<endl;
	  		cin>>x>>y;
	  		if(x<0 || a[x][y]=='F')
	  			return 0;
	  		if(y==1)
	  			swapu=1;
	  		else
	  		{
	  			cout<<"U"<<endl;
	  			cin>>x>>y;
	  			if(a[x][y]=='F')
	  				return 0;
	  			swapu=0;
	  		}
	  		while(a[x][2]=='*')
	  		{
	  			if(swapu)
	  				cout<<"U"<<endl;
	  			else
	  				cout<<"D"<<endl;
	  			cin>>x>>y;
	  			if(x<0 || a[x][y]=='F')
	  				return 0;
	  		}
	  		cout<<"L"<<endl;
	  		cin>>x>>y;
	  		if(x==1)
	  			swapl=1;
	  		else
	  			swapl=0;
	  		memset(visited,0,sizeof(visited));
	  		fin(x,y);
	  		memset(visited,0,sizeof(visited));
	  		print(x,y,swapl,swapu);
  	}
  }
  return 0;
}


/// code mode nakavidam
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define sync()      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fileIO()    freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
#define F           first
#define S           second
#define ers         erase
#define ins         insert
#define db          pop_back
#define pb          push_back
#define df          pop_front
#define pf          push_front
#define SZ(x)       ((ll)x.size())
#define sqr(x)      (x)*(x)
#define Blz(x)      __builtin_clz(x)
#define Brz(x)      __builtin_ctz(x)
#define Bones(x)    __builtin_popcount(x)
#define all(x)      x.begin(),x.end()
#define kill(x)     return cout<<x,0
#define dbgp(x)     cerr<< #x << " = " << x.F << ", " << x.S << endl
#define dbg(x)      cerr<< #x << " = " << x << endl
#define ddbg(i,x)   cerr<< #i << " = " << i << " / ", dbg(x[i])
#define tdbg(i,E,x) cerr<< #i << " = " << i << " / ", ddbg(E,x[i])
typedef long long                                 ll;
typedef long double                               ld;
typedef unsigned short int                        usi;
typedef pair<long long,bool>                      plb;
typedef pair<long long,long long>                 pll;
typedef string                                    str;
typedef priority_queue<ll>                        maxheap;
typedef priority_queue<ll,vector<ll>,greater<ll>> minheap;
typedef priority_queue<pll,vector<pll>,greater<pll>> djq;
const ll maxn=1e2+10, inf=1e9, mod=1e9+7; const ld pi=3.14159265359, eps=1e-9;
ll n,m;
char har[]={'D','U','R','L'};
char t[maxn][maxn];
bool isval(ll x,ll y){ return (x>0 && y>0 && x<=n && y<=m && t[x][y]!='*'); }
bool mk[maxn][maxn]; bool F=0; vector<usi> hr;
void dfs(ll x,ll y){
    if(mk[x][y]) return;
    if(t[x][y]=='F'){ F=1; return; }
    mk[x][y]=1;
    if(isval(x+1,y)){
        hr.pb(0);
        dfs(x+1,y);
        if(F) return;
        hr.db();
    }
    if(isval(x-1,y)){
        hr.pb(1);
        dfs(x-1,y);
        if(F) return;
        hr.db();
    }
    if(isval(x,y+1)){
        hr.pb(2);
        dfs(x,y+1);
        if(F) return;
        hr.db();
    }
    if(isval(x,y-1)){
        hr.pb(3);
        dfs(x,y-1);
        if(F) return;
        hr.db();
    }
}
ll X,Y;
void ask(ll jh){
    cout<<har[jh]<<endl;
    cin>>X>>Y;
}
int main(){
    sync();
    cin>>n>>m;
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++) cin>>t[i][j];
    dfs(1,1);
    //for(ll x:hr) cout<<x<<endl;
    int I=0;
    if(hr[I]<=1){
        if(hr[I]<=1){
            ask(hr[I]);
            if(X==1 && Y==1) swap(har[0],har[1]), I--;
        }
        I++;
        while(I<SZ(hr) && hr[I]<=1) ask(hr[I]), I++;
        ll revx=X,revy=Y;
        if(hr[I]>=2){
            ask(hr[I]);
            if(revx==X && revy==Y) swap(har[2],har[3]), I--;
        }
        I++;
        while(I<SZ(hr)) ask(hr[I]) ,I++;
    }
    else{
        if(hr[I]>=2){
            ask(hr[I]);
            if(X==1 && Y==1) swap(har[2],har[3]), I--;
        }
        I++;
        while(I<SZ(hr) && hr[I]>=2) ask(hr[I]), I++;
        ll revx=X,revy=Y;
        if(hr[I]<=1){
            ask(hr[I]);
            if(revx==X && revy==Y) swap(har[0],har[1]), I--;
        }
        I++;
        while(I<SZ(hr)) ask(hr[I]) ,I++;
    }
    return 0;
}
/**
 (                            )   (   )
 )\ )             (      )  ( /(  () /(
(()/(  (  (    (  )\  ( /(  )\()) )\ ())
 /(_))_)  )\   )\((_) )(_))(_)\) ((_)(_)
(_)) __| ((_) ((_)| |((_)_)| |(_)| |_| |
  | (_ |/ _ \/ _ \| |/ _` || / / |  _  |
   \___|\___/\___/|_|\__,_||_\_\ |_| |_|
**/


////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
#include <chrono>
#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define move kjafkljkl
//#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 100;
string s[N + 5];

int dirx = -1, diry = -1;

int pre[N + 5][N + 5];

bool vis[N + 5][N + 5];

queue<pair<int,int> > q;

int py[] = {1, 0, -1, 0};
int px[] = {0, 1, 0, -1};
string move = "DRUL";

void bt(int y, int x, int mv) {
	if(y != 0 || x != 0) {
		int prey = y + py[pre[y][x]];
		int prex = x + px[pre[y][x]];
		bt(prey, prex, (pre[y][x] + 2) % 4);
	}
	if(mv == -1) return ;
	if(mv % 2) { //x axis
		if(dirx == -1) {
			cout<<move[mv]<<endl;
			int ny, nx;
			cin>>ny>>nx;
			ny--, nx--;
			if(ny == y && nx == x) dirx = 1; //out of bound
			else dirx = 0;
			if(ny == y && nx == x) {
				cout<<move[(mv + 2) % 4]<<endl;
				cin>>ny>>nx;
			}
		}
		else {
			cout<<move[(mv + 2 * dirx) % 4]<<endl;
			int ny, nx;
			cin>>ny>>nx;
		}
	}
	else {
		if(diry == -1) {
			cout<<move[mv]<<endl;
			int ny, nx;
			cin>>ny>>nx;
			ny--, nx--;
			if(ny == y && nx == x) diry = 1; //out of bound
			else diry = 0;
			if(ny == y && nx == x) {
				cout<<move[(mv + 2) % 4]<<endl;
				cin>>ny>>nx;
			}
		}
		else {
			cout<<move[(mv + 2 * diry) % 4]<<endl;
			int ny, nx;
			cin>>ny>>nx;
		}
	}
}

void hora(int tc) {
	int r, c;
	cin>>r>>c;
	for(int i = 0;i < r;i++) cin>>s[i];
	int y = 0, x = 0;
	if(s[0][0] == 'F') return ;
	q.push({0, 0});
	vis[0][0] = 1;

	while(!q.empty()) {
		y = q.front().F;
		x = q.front().S;
		q.pop();
		if(s[y][x] == 'F') break;
		for(int i = 0;i < 4;i++) {
			int ny = y + py[i];
			int nx = x + px[i];
			if(ny < 0 || nx < 0 || ny >= r || nx >= c) continue;
			if(s[ny][nx] == '*') continue;
			if(vis[ny][nx]) continue;
			vis[ny][nx] = 1;
			pre[ny][nx] = (i + 2) % 4;
			q.push({ny, nx});
		}
	}
	bt(y, x, -1);
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 300002;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()
pair<int,int> final;
bool swapup = 0,swapleft = 0;
int n,m;
char a[110][110];
int b[110][110];
int vis[110][110];
pair<int,int> now = {1,1};
pair<int,int> query(char C){
  if(swapup and (C=='U' || C == 'D')){
    C = 'D' + 'U' - C;
  }
  if(swapleft and (C=='L' || C == 'R')){
    C = 'L' + 'R' - C;
  }
  cout<<C<<endl;
  pair<int,int> ans;
  cin>>ans.first>>ans.second;
  if(ans == final || ans.first == -1) exit(0);
  return ans;
}
void special_cases(){
  if(n == 1){
    auto ans = query('R');
    if(ans == now){
      while(true){
        query('L');
      }
    }
    else{
      while(true){
        query('R');
      }
    }
  }

  else if(m == 1){
    auto ans = query('D');
    if(ans == now){
      while(true){
        query('U');
      }
    }
    else{
      while(true){
        query('D');
      }
    }
  }
}
bool isvalid(int i,int j){
  return (i>0 and j>0 and i<=n and j<=m and (b[i][j] == 0));
}
vector<char> path;
char dir[4] = {'L','D','R','U'};
int dx[4] = {0,1,0,-1};
int dy[4] = {-1,0,1,0};
bool dfs(int i,int j){
  if(make_pair(i,j) == final){
    return true;
  }
  vis[i][j] = true;
  for(int k =0;k<4;k++){
    int ni = i+dx[k];
    int nj = j+dy[k];
    if(isvalid(ni,nj) and !vis[ni][nj]){
      path.push_back(dir[k]);
      if(dfs(ni,nj)) return true;
      else path.pop_back();
    }
  }
  return false;
}
int32_t main()
{

  // #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  // #endif
  cin>>n>>m;
  memset(b,0,sizeof(b));
  for(int i = 1;i<=n;i++){
    for(int j = 1;j<=m;j++){
      cin>>a[i][j];
      if(a[i][j] == 'F'){
        final = make_pair(i,j);
      }
      else if(a[i][j] == '*') b[i][j] = 1;
    }
  }

  // special cases
  if(n == 1 || m == 1){
    special_cases();
  }
  if(!a[2][1]){
    auto ans = query('U');
    if(ans != now){
      swapup = 1;
      query('U');
    }
    while(b[now.first][now.second+1]){
      now = query('D');
    }
    ans = query('R');
    if(ans == now){
      swapleft  = 1;
    }
    else{
      query('L');
    }
    while(now != make_pair(1ll,1ll)){
      now = query('U');
    }
  }
  else{
    auto ans = query('L');
    if(ans != now){
      swapleft = 1;
      query('L');
    }
    while(b[now.first+1][now.second]){
      now = query('R');
    }
    ans = query('D');
    if(ans == now){
      swapup  = 1;
    }
    else{
      query('U');
    }
    while(now != make_pair(1ll,1ll)){
      now = query('L');
    }
  }
  dfs(1,1);
  for(auto c:path){
    query(c);
  }

}


//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 300002;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()
pair<int,int> final;
bool swapup = 0,swapleft = 0;
int n,m;
char a[110][110];
int b[110][110];
int vis[110][110];
pair<int,int> now = {1,1};
pair<int,int> query(char C){
  if(swapup and (C=='U' || C == 'D')){
    C = 'D' + 'U' - C;
  }
  if(swapleft and (C=='L' || C == 'R')){
    C = 'L' + 'R' - C;
  }
  cout<<C<<endl;
  pair<int,int> ans;
  cin>>ans.first>>ans.second;
  if(ans == final || ans.first == -1) exit(0);
  return ans;
}
void special_cases(){
  if(n == 1){
    auto ans = query('R');
    if(ans == now){
      while(true){
        query('L');
      }
    }
    else{
      while(true){
        query('R');
      }
    }
  }

  else if(m == 1){
    auto ans = query('D');
    if(ans == now){
      while(true){
        query('U');
      }
    }
    else{
      while(true){
        query('D');
      }
    }
  }
}
bool isvalid(int i,int j){
  return (i>0 and j>0 and i<=n and j<=m and (b[i][j] == 0));
}
vector<char> path;
char dir[4] = {'L','D','R','U'};
int dx[4] = {0,1,0,-1};
int dy[4] = {-1,0,1,0};
bool dfs(int i,int j){
  if(make_pair(i,j) == final){
    return true;
  }
  vis[i][j] = true;
  for(int k =0;k<4;k++){
    int ni = i+dx[k];
    int nj = j+dy[k];
    if(isvalid(ni,nj) and !vis[ni][nj]){
      path.push_back(dir[k]);
      if(dfs(ni,nj)) return true;
      else path.pop_back();
    }
  }
  return false;
}
int32_t main()
{

  // #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  // #endif
  cin>>n>>m;
  memset(b,0,sizeof(b));
  for(int i = 1;i<=n;i++){
    for(int j = 1;j<=m;j++){
      cin>>a[i][j];
      if(a[i][j] == 'F'){
        final = make_pair(i,j);
      }
      else if(a[i][j] == '*') b[i][j] = 1;
    }
  }

  // special cases
  if(n == 1 || m == 1){
    special_cases();
    return 0;
  }
  if(!b[2][1]){
    auto ans = query('U');
    if(ans != now){
      swapup = 1;
      query('U');
    }
    while(b[now.first][now.second+1]){
      now = query('D');
    }
    ans = query('R');
    if(ans == now){
      swapleft  = 1;
    }
    else{
      query('L');
    }
    while(now != make_pair(1ll,1ll)){
      now = query('U');
    }
  }
  else{
    auto ans = query('L');
    if(ans != now){
      swapleft = 1;
      query('L');
    }
    while(b[now.first+1][now.second]){
      now = query('R');
    }
    ans = query('D');
    if(ans == now){
      swapup  = 1;
    }
    else{
      query('U');
    }
    while(now != make_pair(1ll,1ll)){
      now = query('L');
    }
  }
  dfs(1,1);
  for(auto c:path){
    query(c);
  }

}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>
#include <random>
#include <unordered_map>
#include <ctime>
typedef  long long ll;
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef pair<int, int> pii;
typedef long double ld;
typedef unsigned int uint;
#define MAX 5105
bool debug = 0;
int n,m,k;
//int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod = MOD) {
    assert(y>=0);
    x+=y; if (x>=mod) x-=mod;
    assert(x>=0 && x<mod);
}
void et() {
    puts("-1"); exit(0);
}

char s[MAX][MAX];
int dx[4] = {0,0,-1,1}, dy[4] = {-1,1,0,0};
string str="LRUD";
int X=1,Y=1;
void rd(int pos) {
    printf("%c\n", str[pos]); fflush(stdout);
    int a,b; scanf("%d%d", &a, &b); X=a;Y=b;
    if (s[a][b]=='F') exit(0);
}
int dis[MAX][MAX];
void cal() {
    queue<pii> q;
    REQ(i,n) REQ(j,m) if (s[i][j]=='F') {
        dis[i][j]=1;
        q.push({i,j}); break;
    }
    while(!q.empty()) {
        auto p = q.front(); q.pop();
        int i=p.first, j=p.second;
        REP(k,4) {
            int x = dx[k]+i,y=dy[k]+j;
            if (s[x][y]=='.' && dis[x][y]==0) {
                dis[x][y] = dis[i][j]+1;
                q.push({x,y});
            }
        }
    }
    while (s[X][Y]!='F') {
        REP(k,4) {
            int x = dx[k]+X,y=dy[k]+Y;
            if (dis[x][y]==dis[X][Y]-1) {
                rd(k); break;
            }
        }
    }
}
void fmain(int tid) {
    scanf("%d%d", &n, &m);
    REQ(i,n) scanf("%s", s[i]+1);
    if (n==1) {
        rd(0);
        if (Y==2)swap(str[0],str[1]);
        while (s[X][Y]!='F') rd(1);
        return;
    }
    if (m==1) {
        rd(2);
        if (X==2) swap(str[2],str[3]);
        while (s[X][Y]!='F') rd(3);
        return;
    }

    if (s[1][2] != '*') {
        rd(0);
        if (Y==2) {
            swap(str[0],str[1]); rd(0);
        }
        while(Y+1<=m && s[X][Y+1]!='*') {
            rd(1);
            if (s[2][Y] != '*') {
                rd(2);
                if (X==2) {
                    swap(str[2],str[3]); rd(2);
                }
                break;
            }
        }
        assert(X==1);
        while (Y!=1) rd(0);
    }
    if (s[2][1] != '*') {
        rd(2);
        if (X==2) {
            swap(str[2],str[3]); rd(2);
        }
        while (X+1<=n && s[X+1][Y]!='*') {
            rd(3);
            if (s[X][Y+1] != '*') {
                rd(0);
                if (Y==2) {
                    swap(str[0], str[1]); rd(0);
                }
                break;
            }
        }
        assert(Y==1); while(X!=1) rd(2);
    }
    cal();
}

int main() {
    int t=1;
//    scanf("%d", &t);
    REQ(i,t) {
        fmain(i);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef  long long ll;
const ll N=105 ;
const ll mod=1e9 + 7;
#define debug(x) cerr<<#x<<" is "<<x<<endl;

ll n,m;
bool vis[N][N];
string s[N];
char dir[]={'U' , 'L' , 'D' , 'R' };
ll dx[]={-1,0,1,0};
ll dy[]={0,-1,0,1};
bool chk(ll x,ll y){
    return (0<=x && x<n) && (0<=y && y<m) && (s[x][y]!='*' && !vis[x][y]);
}
void dfs(ll x,ll y,ll tt){
    vis[x][y]=true;
    if(s[x][y]=='F')exit(0);
    for(ll i=0;i<4;i++){
        ll nx = x+dx[i] , ny = y+dy[i];
        if(chk(nx,ny)){
            cout<<dir[i]<<endl;
            ll tx,ty;
            cin>>tx>>ty;
            tx-=1;ty-=1;
            if(x==tx && y==ty){
                swap(dir[i] , dir[(i+2)%4]);
                cout<<dir[i]<<endl;
                cin>>tx>>ty;
            }
            dfs(nx,ny,i);
        }
    }
    cout<<dir[(tt+2)%4]<<endl;
    ll tx,ty;
    cin>>tx>>ty;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    for(ll i=0;i<n;i++)cin>>s[i];
    dfs(0,0,-1);

}


/*
author: Edward Johnson(Manchester_UNITED)
problem: 811D Vladik and Favorite Game
time: 2020.06.20 01:17:00
last verdict: WA on test 11
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define inf 1000000000
#define inf64 1000000000000000000
#define X first
#define Y second
#define ll long long
using namespace std;
const int maxn=111;
ll n,m,dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
bool swaplr,swapud,vis[maxn][maxn];
char grid[maxn][maxn];
void dfs(ll x,ll y){
	vis[x][y]=true;
	if(grid[x][y]=='F') exit(0);
	for(int i=0;i<4;i++){
		ll tx=x+dx[i];
		ll ty=y+dy[i];
		if(tx<0||tx>=n||ty<0||ty>=m) continue;
		if(grid[tx][ty]=='*'||vis[tx][ty]) continue;
		if(tx==x+1){
			if(swapud) cout<<"U"<<endl;
			else cout<<"D"<<endl;
			fflush(stdout);
		}
		else if(tx==x-1){
			if(!swapud) cout<<"U"<<endl;
			else cout<<"D"<<endl;
			fflush(stdout);
		}
		else if(ty==y+1){
			if(swaplr) cout<<"L"<<endl;
			else cout<<"R"<<endl;
			fflush(stdout);
		}
		else{
			if(!swaplr) cout<<"L"<<endl;
			else cout<<"R"<<endl;
			fflush(stdout);
		}
		cin>>tx>>ty;
		tx--,ty--;
		dfs(tx,ty);
		if(tx==x+1){
			if(!swapud) cout<<"U"<<endl;
			else cout<<"D"<<endl;
			fflush(stdout);
		}
		else if(tx==x-1){
			if(swapud) cout<<"U"<<endl;
			else cout<<"D"<<endl;
			fflush(stdout);
		}
		else if(ty==y+1){
			if(!swaplr) cout<<"L"<<endl;
			else cout<<"R"<<endl;
			fflush(stdout);
		}
		else{
			if(swaplr) cout<<"L"<<endl;
			else cout<<"R"<<endl;
			fflush(stdout);
		}
		cin>>tx>>ty;
		tx--,ty--;
	}
	return;
}
int main(){
	ll x=0,y=0;
	cin>>n>>m;
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>grid[i][j];
	if(grid[0][1]=='.'){
		cout<<"R"<<endl;
		fflush(stdout);
		cin>>x>>y;
		x--,y--;
		if(x==0&&y==0) swaplr=true;
		else swaplr=false;
		if(x!=0||y!=0){
			cout<<"L"<<endl;
			fflush(stdout);
			cin>>x>>y;
			x--,y--;
		}
		if(n==1){
			while(grid[x][y]=='.'){
				if(swaplr) cout<<"L"<<endl;
				else cout<<"R"<<endl;
				fflush(stdout);
				cin>>x>>y;
				x--,y--;
			}
			return 0;
		}
		while(grid[x+1][y]=='*'){
			if(swaplr) cout<<"L"<<endl;
			else cout<<"R"<<endl;
			fflush(stdout);
			cin>>x>>y;
			x--,y--;
			if(grid[x][y]=='F') return 0;
		}
		cout<<"D"<<endl;
		fflush(stdout);
		cin>>x>>y;
		x--,y--;
		if(x==0) swapud=true;
		else swapud=false;
	}
	else{
		cout<<"D"<<endl;
		fflush(stdout);
		cin>>x>>y;
		x--,y--;
		if(x==0&&y==0) swapud=true;
		else swapud=false;
		if(x!=0||y!=0){
			cout<<"U"<<endl;
			fflush(stdout);
			cin>>x>>y;
			x--,y--;
		}
		if(m==1){
			while(grid[x][y]=='.'){
				if(swapud) cout<<"U"<<endl;
				else cout<<"D"<<endl;
				fflush(stdout);
				cin>>x>>y;
				x--,y--;
			}
			return 0;
		}
		while(grid[x][y+1]=='*'){
			if(swapud) cout<<"U"<<endl;
			else cout<<"D"<<endl;
			fflush(stdout);
			cin>>x>>y;
			x--,y--;
			if(grid[x][y]=='F') return 0;
		}
		cout<<"R"<<endl;
		fflush(stdout);
		cin>>x>>y;
		x--,y--;
		if(y==0) swaplr=true;
		else swaplr=false;
	}
	dfs(x,y);
	return 0;
}


/*
author: Edward Johnson(Manchester_UNITED)
problem: 811D Vladik and Favorite Game
time: 2020.06.20 01:36:07
last verdict: WA on test 2
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define inf 1000000000
#define inf64 1000000000000000000
#define X first
#define Y second
#define ll long long
using namespace std;
const int maxn=111;
ll n,m,dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
bool swaplr,swapud,vis[maxn][maxn];
char grid[maxn][maxn];
void dfs(ll x,ll y){
	vis[x][y]=true;
	if(grid[x][y]=='F') exit(0);
	for(int i=0;i<4;i++){
		ll tx=x+dx[i];
		ll ty=y+dy[i];
		if(tx<0||tx>=n||ty<0||ty>=m) continue;
		if(grid[tx][ty]=='*'||vis[tx][ty]) continue;
		if(tx==x+1){
			if(swapud) cout<<"U"<<endl;
			else cout<<"D"<<endl;
			fflush(stdout);
		}
		else if(tx==x-1){
			if(!swapud) cout<<"U"<<endl;
			else cout<<"D"<<endl;
			fflush(stdout);
		}
		else if(ty==y+1){
			if(swaplr) cout<<"L"<<endl;
			else cout<<"R"<<endl;
			fflush(stdout);
		}
		else{
			if(!swaplr) cout<<"L"<<endl;
			else cout<<"R"<<endl;
			fflush(stdout);
		}
		cin>>tx>>ty;
		tx--,ty--;
		dfs(tx,ty);
		if(tx==x+1){
			if(!swapud) cout<<"U"<<endl;
			else cout<<"D"<<endl;
			fflush(stdout);
		}
		else if(tx==x-1){
			if(swapud) cout<<"U"<<endl;
			else cout<<"D"<<endl;
			fflush(stdout);
		}
		else if(ty==y+1){
			if(!swaplr) cout<<"L"<<endl;
			else cout<<"R"<<endl;
			fflush(stdout);
		}
		else{
			if(swaplr) cout<<"L"<<endl;
			else cout<<"R"<<endl;
			fflush(stdout);
		}
		cin>>tx>>ty;
		tx--,ty--;
	}
	return;
}
int main(){
	ll x=0,y=0;
	cin>>n>>m;
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>grid[i][j];
	vis[0][0]=true;
	if(grid[0][1]=='.'){
		cout<<"R"<<endl;
		fflush(stdout);
		cin>>x>>y;
		x--,y--;
		vis[x][y]=true;
		if(x==0&&y==0) swaplr=true;
		else swaplr=false;
		if(x!=0||y!=0){
			cout<<"L"<<endl;
			fflush(stdout);
			cin>>x>>y;
			x--,y--;
		}
		if(n==1){
			while(grid[x][y]=='.'){
				if(swaplr) cout<<"L"<<endl;
				else cout<<"R"<<endl;
				fflush(stdout);
				cin>>x>>y;
				x--,y--;
				vis[x][y]=true;
			}
			return 0;
		}
		while(grid[x+1][y]=='*'){
			if(swaplr) cout<<"L"<<endl;
			else cout<<"R"<<endl;
			fflush(stdout);
			cin>>x>>y;
			x--,y--;
			vis[x][y]=true;
			if(grid[x][y]=='F') return 0;
		}
		cout<<"D"<<endl;
		fflush(stdout);
		cin>>x>>y;
		x--,y--;
		vis[x][y]=true;
		if(x==0) swapud=true;
		else swapud=false;
	}
	else{
		cout<<"D"<<endl;
		fflush(stdout);
		cin>>x>>y;
		x--,y--;
		vis[x][y]=true;
		if(x==0&&y==0) swapud=true;
		else swapud=false;
		if(x!=0||y!=0){
			cout<<"U"<<endl;
			fflush(stdout);
			cin>>x>>y;
			x--,y--;
		}
		if(m==1){
			while(grid[x][y]=='.'){
				if(swapud) cout<<"U"<<endl;
				else cout<<"D"<<endl;
				fflush(stdout);
				cin>>x>>y;
				x--,y--;
				vis[x][y]=true;
			}
			return 0;
		}
		while(grid[x][y+1]=='*'){
			if(swapud) cout<<"U"<<endl;
			else cout<<"D"<<endl;
			fflush(stdout);
			cin>>x>>y;
			x--,y--;
			vis[x][y]=true;
			if(grid[x][y]=='F') return 0;
		}
		cout<<"R"<<endl;
		fflush(stdout);
		cin>>x>>y;
		x--,y--;
		vis[x][y]=true;
		if(y==0) swaplr=true;
		else swaplr=false;
	}
	dfs(x,y);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(a, b, c, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rep2(i, a) rep3 (i, 0, a)
#define rep3(i, a, b) for (int i = (a); i < (b); i++)
#define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__)
#define repr2(i, a) repr3 (i, 0, a)
#define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--)
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
using ll = long long;

const ll mod = 1e9 + 7;

int main() {
	ll n, m;
	cin >> n >> m;

	map<ll, pair<ll, ll>> mp;

	ll i = 1;
	ll num = 0;
	while (i <= m) {
		ll low = i, high = m + 1;
		while (high - low > 1) {
			num++;
			ll mid = (low + high) / 2;
			if (n / mid < n / i) {
				high = mid;
			} else {
				low = mid;
			}
		}
		mp[n / i] = {i, high};
		i = high;
	}

	ll ans = 0;
	for (auto p : mp) {
		ll l, r;
		tie(l, r) = p.second;
		ll sum = (l + r - 1) * (r - l) / 2 % mod;
		ans += p.first * sum;
		ans %= mod;
	}
	ans = n * m - ans;
	ans %= mod; ans += mod; ans %= mod;
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(a, b, c, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rep2(i, a) rep3 (i, 0, a)
#define rep3(i, a, b) for (int i = (a); i < (b); i++)
#define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__)
#define repr2(i, a) repr3 (i, 0, a)
#define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--)
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
using ll = long long;

const ll mod = 1e9 + 7;

ll modpow(ll a, ll b, ll mod) {
	ll res = 1;
	for (; b > 0; a = a * a % mod, b /= 2) if (b & 1) res = res * a % mod;
	return res;
}

ll modinv(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}

int main() {
	ll n, m;
	cin >> n >> m;

	vector<int> next(5050505, -1);
	repr (i, 1, 5050505 - 1) {
		if (n / (i + 1) == n / i) {
			next[i] = next[i + 1];
		} else {
			next[i] = i + 1;
		}
	}

	ll i = 1;
	ll num = 0;
	ll inv = modinv(2, mod);
	ll ans = 0;
	while (i <= m) {
		ll low = i, high = m + 1;
		if (i >= 5050505 || next[i] == -1) {
			while (high - low > 1) {
				ll mid = (low + high) / 2;
				if (n / mid < n / i) {
					high = mid;
				} else {
					low = mid;
				}
			}
		} else {
			high = min<ll>(m + 1, next[i]);
		}
		ll l = i, r = high;
		ll sum = (l + r - 1) % mod * (r - l) % mod * inv % mod;
		ans += (n / i) % mod * sum;
		ans %= mod;
		i = high;
	}

	ans = n * m - ans;
	ans %= mod; ans += mod; ans %= mod;
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(a, b, c, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rep2(i, a) rep3 (i, 0, a)
#define rep3(i, a, b) for (int i = (a); i < (b); i++)
#define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__)
#define repr2(i, a) repr3 (i, 0, a)
#define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--)
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
using ll = long long;

const ll mod = 1e9 + 7;

ll modpow(ll a, ll b, ll mod) {
	ll res = 1;
	for (; b > 0; a = a * a % mod, b /= 2) if (b & 1) res = res * a % mod;
	return res;
}

ll modinv(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}

int main() {
	ll n, m;
	cin >> n >> m;

	vector<int> next(5050505, -1);
	repr (i, 1, 5050505 - 1) {
		if (n / (i + 1) == n / i) {
			next[i] = next[i + 1];
		} else {
			next[i] = i + 1;
		}
	}

	ll i = 1;
	ll num = 0;
	ll inv = modinv(2, mod);
	ll ans = 0;
	while (i <= m) {
		ll low = i, high = m + 1;
		if (i >= 5050505 || next[i] == -1) {
			while (high - low > 1) {
				ll mid = (low + high) / 2;
				if (n / mid < n / i) {
					high = mid;
				} else {
					low = mid;
				}
			}
		} else {
			high = min<ll>(m + 1, next[i]);
		}
		ll l = i, r = high;
		ll sum = (l + r - 1) % mod * (r - l) % mod * inv % mod;
		ans += (n / i) * sum;
		i = high;
		ans %= mod;
	}

	ans = n * m - ans;
	ans %= mod; ans += mod; ans %= mod;
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(a, b, c, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rep2(i, a) rep3 (i, 0, a)
#define rep3(i, a, b) for (int i = (a); i < (b); i++)
#define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__)
#define repr2(i, a) repr3 (i, 0, a)
#define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--)
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
using ll = long long;

const ll mod = 1e9 + 7;

ll modpow(ll a, ll b, ll mod) {
	ll res = 1;
	for (; b > 0; a = a * a % mod, b /= 2) if (b & 1) res = res * a % mod;
	return res;
}

ll modinv(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}

int main() {
	ll n, m;
	cin >> n >> m;

	vector<int> next(5050505, -1);
	repr (i, 1, 5050505 - 1) {
		if (n / (i + 1) == n / i) {
			next[i] = next[i + 1];
		} else {
			next[i] = i + 1;
		}
	}

	ll i = 1;
	ll num = 0;
	ll inv = modinv(2, mod);
	ll ans = 0;
	while (i <= m) {
		if (n / i == 0) break;
		ll low = i - 1, high = m + 1;
		if (i >= 5050505 || next[i] == -1) {
			while (high - low > 1) {
				ll mid = (low + high) / 2;
				if (n / mid < n / i) {
					high = mid;
				} else {
					low = mid;
				}
			}
		} else {
			high = min<ll>(m + 1, next[i]);
		}
		ll l = i % mod, r = high % mod;
		ll sum = (l + r - 1) * (r - l) % mod * inv % mod;
		ans += (n / i) % mod * sum;
		ans %= mod;
		i = high;
	}

	ans = (n % mod) * (m % mod) - ans;
	ans %= mod; ans += mod; ans %= mod;
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(a, b, c, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rep2(i, a) rep3 (i, 0, a)
#define rep3(i, a, b) for (int i = (a); i < (b); i++)
#define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__)
#define repr2(i, a) repr3 (i, 0, a)
#define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--)
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
using ll = long long;

const ll mod = 1e9 + 7;

ll modpow(ll a, ll b, ll mod) {
	ll res = 1;
	for (; b > 0; a = a * a % mod, b /= 2) if (b & 1) res = res * a % mod;
	return res;
}

ll modinv(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}

int main() {
	ll n, m;
	cin >> n >> m;

	ll i = 1;
	ll ans = 0;

	ll left = m + 1;
	ll inv = modinv(2, mod);
	for (ll i = 1; i * i <= n; i++) {
		ll l = n / (i + 1) + 1;
		ll r = min(n / i + 1, m + 1);
		if (l >= r) continue;
		left = l;
		ll sum = (l + r - 1) * (r - l) % mod * inv % mod;
		ans += i * sum;
		ans %= mod;
	}
	for (ll i = 1; i < left; i++) {
		ans += n / i * i;
	}

	ans = (n % mod) * (m % mod) - ans;
	ans %= mod; ans += mod; ans %= mod;
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(a, b, c, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rep2(i, a) rep3 (i, 0, a)
#define rep3(i, a, b) for (int i = (a); i < (b); i++)
#define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__)
#define repr2(i, a) repr3 (i, 0, a)
#define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--)
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
using ll = long long;

const ll mod = 1e9 + 7;

ll modpow(ll a, ll b, ll mod) {
	ll res = 1;
	for (; b > 0; a = a * a % mod, b /= 2) if (b & 1) res = res * a % mod;
	return res;
}

ll modinv(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}

int main() {
	ll n, m;
	cin >> n >> m;

	ll i = 1;
	ll ans = 0;

	for (ll i = 1; i * i < n && i <= m + 1; i++) {
		ans += (n / i) % mod;
		i++;
	}

	ll inv = modinv(2, mod);
	for (ll i = 1; i * i <= n; i++) {
		ll l = min(n / (i + 1) + 1, m + 1);
		ll r = min(n / i + 1, m + 1);
		l %= mod; r %= mod;
		ll sum = (l + r - 1) * (r - l) % mod * inv % mod;
		ans += i * sum;
		ans %= mod;
	}

	ans = (n % mod) * (m % mod) - ans;
	ans %= mod; ans += mod; ans %= mod;
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(a, b, c, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rep2(i, a) rep3 (i, 0, a)
#define rep3(i, a, b) for (int i = (a); i < (b); i++)
#define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__)
#define repr2(i, a) repr3 (i, 0, a)
#define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--)
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
using ll = long long;

const ll mod = 1e9 + 7;

ll modpow(ll a, ll b, ll mod) {
	ll res = 1;
	for (; b > 0; a = a * a % mod, b /= 2) if (b & 1) res = res * a % mod;
	return res;
}

ll modinv(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}

int main() {
	ll n, m;
	cin >> n >> m;

	ll i = 1;
	ll ans = 0;

	ll left = m + 1;
	ll inv = modinv(2, mod);
	for (ll i = 1; i * i <= n; i++) {
		ll l = n / (i + 1) + 1;
		ll r = min(n / i + 1, m + 1);
		if (l >= r) continue;
		left = l;
		l %= mod; r %= mod;
		ll sum = (l + r - 1) * (r - l) % mod * inv % mod;
		ans += i * sum;
		ans %= mod;
	}
	for (ll i = 1; i < left; i++) {
		ans += n / i * i;
	}

	ans = (n % mod) * (m % mod) - ans;
	ans %= mod; ans += mod; ans %= mod;
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(a, b, c, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rep2(i, a) rep3 (i, 0, a)
#define rep3(i, a, b) for (int i = (a); i < (b); i++)
#define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__)
#define repr2(i, a) repr3 (i, 0, a)
#define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--)
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
using ll = long long;

const ll mod = 1e9 + 7;

ll modpow(ll a, ll b, ll mod) {
	ll res = 1;
	for (; b > 0; a = a * a % mod, b /= 2) if (b & 1) res = res * a % mod;
	return res;
}

ll modinv(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}

int main() {
	ll n, m;
	cin >> n >> m;

	ll i = 1;
	ll ans = 0;

	ll left = m + 1;
	ll inv = modinv(2, mod);
	for (ll i = 1; i * i <= n; i++) {
		ll l = n / (i + 1) + 1;
		ll r = min(n / i + 1, m + 1);
		if (l >= r) continue;
		left = l;
		l %= mod; r %= mod;
		ll sum = (l + r - 1) * (r - l) % mod * inv % mod;
		ans += i * sum;
		ans %= mod;
	}
	for (ll i = 1; i < left; i++) {
		ans += n / i * i;
		ans %= mod;
	}

	ans = (n % mod) * (m % mod) - ans;
	ans %= mod; ans += mod; ans %= mod;
	cout << ans << endl;
	return 0;
}


//
//  Created by TaoSama on 2016-01-13
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

typedef long long LL;
LL n, m;

LL get(LL l, LL r) {
    int Q = 2 * MOD;
    return (l + 1 + r) % Q * (r - l) % Q / 2;
}

int main() {
#ifdef LOCAL
    freopen("C:\\Users\\TaoSama\\Desktop\\in.txt", "r", stdin);
//  freopen("C:\\Users\\TaoSama\\Desktop\\out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(scanf("%I64d%I64d", &n, &m) == 2) {
        LL ans = n % MOD * m % MOD % MOD, to;
        m = min(n, m);
        for(LL i = n / m; i * i <= n; ++i) {
            LL l = n / (i + 1), r = min(n / i, m); //(l, r]
            to = l;
            ans = (ans - get(l, r) * i % MOD) % MOD;
        }
        for(int i = 1; i <= to; ++i)
            ans = (ans - n / i * i % MOD) % MOD;
        ans = (ans + MOD) % MOD;
        printf("%I64d\n", ans);
    }
    return 0;
}


//
//  Created by TaoSama on 2016-01-13
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>
#include <cassert>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

typedef long long LL;
LL n, m;

LL get(LL l, LL r) {
    LL Q = 2 * MOD;
    return (l + 1 + r) % Q * ((r - l) % Q) % Q / 2;
}

int main() {
#ifdef LOCAL
    freopen("C:\\Users\\TaoSama\\Desktop\\in.txt", "r", stdin);
//  freopen("C:\\Users\\TaoSama\\Desktop\\out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(scanf("%I64d%I64d", &n, &m) == 2) {
        LL ans = n % MOD * (m % MOD) % MOD, t;
        m = min(n, m);
        for(t = 1; t <= m && t * t <= n; ++t)
			ans = (ans - n / t * t % MOD) % MOD;
		prln(ans);
		for(LL i = n / t; i >= n / m; --i){
			LL l = n / (i + 1), r = min(n / i, m); //(l, r]
			ans = (ans - get(l, r) * i) % MOD;
		}
        printf("%I64d\n", (ans + MOD) % MOD);
    }
    return 0;
}


//
//  Created by TaoSama on 2016-01-13
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

typedef long long LL;
LL n, m;

LL get(LL l, LL r){
	int Q = 2 * MOD;
	return (l + 1 + r) % Q * (r - l) % Q / 2;
}

int main() {
#ifdef LOCAL
    freopen("C:\\Users\\TaoSama\\Desktop\\in.txt", "r", stdin);
//  freopen("C:\\Users\\TaoSama\\Desktop\\out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(scanf("%I64d%I64d", &n, &m) == 2) {
        LL ans = n % MOD * m % MOD % MOD, to;
        m = min(n, m);
		for(LL i = n / m; i * i <= n; ++i){
			LL l = n / (i + 1), r = min(n / i, m); //(l, r]
			to = l;
			ans = (ans - get(l, r) * i % MOD) % MOD;
		}
		for(int i = 1; i <= to; ++i)
			ans = (ans - n / i * i % MOD) % MOD;
		printf("%I64d\n", ans);
    }
    return 0;
}


//
//  Created by TaoSama on 2016-01-13
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>
#include <cassert>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

typedef long long LL;
LL n, m;

LL get(LL l, LL r) {
    LL Q = 2 * MOD;
    return (l + 1 + r) % Q * ((r - l) % Q) % Q / 2;
}

int main() {
#ifdef LOCAL
    freopen("C:\\Users\\TaoSama\\Desktop\\in.txt", "r", stdin);
//  freopen("C:\\Users\\TaoSama\\Desktop\\out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(scanf("%I64d%I64d", &n, &m) == 2) {
        LL ans = n % MOD * (m % MOD) % MOD, t;
        m = min(n, m);
        for(t = 1; t * t <= n; ++t)
			ans = (ans - n / t * t % MOD) % MOD;
		for(LL i = n / t; i >= n / m; --i){
			LL l = n / (i + 1), r = min(n / i, m); //(l, r]
			ans = (ans - get(l, r) * i) % MOD;
		}
        printf("%I64d\n", (ans + MOD) % MOD);
    }
    return 0;
}


//
//  Created by TaoSama on 2016-01-13
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>
#include <cassert>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

typedef long long LL;
LL n, m;

LL get(LL l, LL r) {
    LL Q = 2 * MOD;
    return (l + 1 + r) % Q * ((r - l) % Q) % Q / 2;
}

int main() {
#ifdef LOCAL
    freopen("C:\\Users\\TaoSama\\Desktop\\in.txt", "r", stdin);
//  freopen("C:\\Users\\TaoSama\\Desktop\\out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(scanf("%I64d%I64d", &n, &m) == 2) {
        LL ans = n % MOD * (m % MOD) % MOD, t;
        m = min(n, m);
        for(t = 1; t <= m && t * t <= n; ++t)
			ans = (ans - n / t * t % MOD) % MOD;
		for(LL i = n / t; i >= n / m; --i){
			LL l = n / (i + 1), r = min(n / i, m); //(l, r]
			ans = (ans - get(l, r) * i) % MOD;
		}
        printf("%I64d\n", (ans + MOD) % MOD);
    }
    return 0;
}


//
//  Created by TaoSama on 2016-01-13
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>
#include <cassert>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

typedef long long LL;
LL n, m;

LL get(LL l, LL r) {
    LL Q = 2 * MOD;
    return (l + 1 + r) % Q * ((r - l) % Q) % Q / 2;
}

int main() {
#ifdef LOCAL
    freopen("C:\\Users\\TaoSama\\Desktop\\in.txt", "r", stdin);
//  freopen("C:\\Users\\TaoSama\\Desktop\\out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(scanf("%I64d%I64d", &n, &m) == 2) {
        LL ans = n % MOD * (m % MOD) % MOD;
        m = min(n, m);
        LL to = m;
        for(LL i = n / m; i * i <= n; ++i) {
            LL l = n / (i + 1), r = min(n / i, m); //(l, r]
            to = l;
            assert(l <= r);
            ans = (ans - get(l, r) * i % MOD) % MOD;
        }
        for(LL i = 1; i <= to; ++i)
            ans = (ans - n / i * i % MOD) % MOD;
        ans = (ans + MOD) % MOD;
        printf("%I64d\n", ans);
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long d2;

long long powmod(long long b, long long e, long long m){
    if(!e)
        return 1;
    if(e&1)
        return (b * powmod(b,e-1,m))%m;
    long long r = powmod(b,e/2,m);
    return (r*r)%m;

}

const long long mod = 1000000007LL;

long long sumPa(long long a1, long long an, long long n){
    return (((((a1+an)%mod)*(n%mod))%mod)*d2)%mod;
}

long long n,m;

long long H(long long D,long long N){
    long long sum = 0;

    long long last = 0;

    for(long long i = 1;i*i<=D && i<=N;i++){
        last = D/i;
        long long xd = last%mod;
        sum = (sum + xd*(i%mod))%mod;
    }

    for(long long f = 1;f*f<D;f++){

        long long A = ceil((D+1)/((double)(f+1)));
        long long B = min(N,D/f);
        if(A>B)continue;
        sum = (sum + (sumPa(A,B,B-A+1) * (f%mod)))%mod;
    }
    return sum;
}

int main(){
    d2 = powmod(2,mod-2,mod);
    long long n,m;
    cin>>n>>m;
    long long ans = 0;
    if(m>=n){
        long long aux = n%mod;
        long long aux2 = m%mod;
        ans=(ans + (aux*(aux2-aux))%mod + mod)%mod;
        m = n-1;
    }
    long long xd = ((n%mod)*(m%mod))%mod;
    cout<<((ans + xd - H(n,m) + 2*mod)%mod)<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long d2;

long long powmod(long long b, long long e, long long m){
    if(!e)
        return 1;
    if(e&1)
        return (b * powmod(b,e-1,m))%m;
    long long r = powmod(b,e/2,m);
    return (r*r)%m;

}

const long long mod = 1000000007LL;

long long sumPa(long long a1, long long an, long long n){
    return (((((a1+an)%mod)*(n%mod))%mod)*d2)%mod;
}

long long n,m;

long long H(long long D,long long N){
    long long sum = 0;

    long long last = 0;

    long long show = min(D,N);

    for(long long f = 1;f*f<=D;f++){

        long long A = D/(f+1) + 1;
        long long B = min(N,D/f);
        if(A>B)continue;
        show = A;
        sum = (sum + (sumPa(A,B,B-A+1) * (f%mod)))%mod;
    }

    for(long long i = 1; i<show;i++){
        long long xd = (D/i)%mod;
        sum = (sum + xd*(i%mod))%mod;
    }
    return sum;
}

int main(){
    d2 = powmod(2,mod-2,mod);
    long long n,m;
    cin>>n>>m;
    long long ans = 0;
    if(m>=n){
        long long aux = n%mod;
        long long aux2 = m%mod;
        ans=(ans + (aux*(aux2-aux))%mod + mod)%mod;
        m = n-1;
    }
    long long xd = ((n%mod)*(m%mod))%mod;
    cout<<((ans + xd - H(n,m) + 2*mod)%mod)<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long d2;

long long powmod(long long b, long long e, long long m){
    if(!e)
        return 1;
    if(e&1)
        return (b * powmod(b,e-1,m))%m;
    long long r = powmod(b,e/2,m);
    return (r*r)%m;

}

const long long mod = 1000000007LL;

long long sumPa(long long a1, long long an, long long n){
    return (((((a1+an)%mod)*(n%mod))%mod)*d2)%mod;
}

long long n,m;

long long H(long long D,long long N){
    long long sum = 0;

    long long last = 0;

    long long show = min(D,N)+1;

    for(long long f = 1;f*f<=D;f++){
        long long A = D/(f+1) + 1;
        long long B = min(N,D/f);
        if(A>B)continue;
        show = min(show,min(A,B));
        sum = (sum + (sumPa(A,B,B-A+1) * (f%mod)))%mod;
    }

    for(long long i = 1; i<show;i++){
        long long xd = (D/i)%mod;
        sum = (sum + xd*(i%mod))%mod;
    }

    return sum;
}

int main(){
    d2 = powmod(2,mod-2,mod);
    long long n,m;
    cin>>n>>m;
    long long ans = 0;
    if(m>=n){
        long long aux = n%mod;
        long long aux2 = m%mod;
        ans=(ans + (aux*(aux2-aux))%mod + mod)%mod;
        m = n-1;
    }
    long long xd = ((n%mod)*(m%mod))%mod;

    cout<<((ans + xd - H(n,m) + 2*mod)%mod)<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long d2;

long long powmod(long long b, long long e, long long m){
    if(!e)
        return 1;
    if(e&1)
        return (b * powmod(b,e-1,m))%m;
    long long r = powmod(b,e/2,m);
    return (r*r)%m;

}

const long long mod = 1000000007LL;

long long sumPa(long long a1, long long an, long long n){
    return (((((a1+an)%mod)*(n%mod))%mod)*d2)%mod;
}

long long n,m;

long long H(long long D,long long N){
    long long sum = 0;

    long long last = 0;

    for(long long i = 1;i*i<=D && i<=N;i++){
        last = D/i;
        long long xd = last%mod;
        sum = (sum + xd*(i%mod))%mod;
    }

    for(long long f = 1;f*f<D && f<last;f++){

        long long A = ceil((D+1)/((double)(f+1)));
        long long B = min(N,D/f);
        if(A>B)continue;
        sum = (sum + (sumPa(A,B,B-A+1) * (f%mod)))%mod;
    }
    return sum;
}

int main(){
    d2 = powmod(2,mod-2,mod);
    long long n,m;
    cin>>n>>m;
    long long ans = 0;
    if(m>=n){
        long long aux = n%mod;
        long long aux2 = m%mod;
        ans=(ans + (aux*(aux2-aux))%mod + mod)%mod;
        m = n-1;
    }
    long long xd = ((n%mod)*(m%mod))%mod;
    cout<<((ans + xd - H(n,m) + 2*mod)%mod)<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long d2;

long long powmod(long long b, long long e, long long m){
    if(!e)
        return 1;
    if(e&1)
        return (b * powmod(b,e-1,m))%m;
    long long r = powmod(b,e/2,m);
    return (r*r)%m;

}

const long long mod = 1000000007LL;

long long sumPa(long long a1, long long an, long long n){
    return (((((a1+an)%mod)*(n%mod))%mod)*d2)%mod;
}

long long n,m;

long long H(long long D,long long N){
    long long sum = 0;

    long long last = 0;

    for(long long i = 1;i*i<=min(D,N);i++){
        last = D/i;
        long long xd = last%mod;
        while(last == (D/i)){
            sum = (sum + xd*(i%mod))%mod;
            i++;
        }
        i--;
    }
    for(long long f = 1;f<last;f++){
        long long A = ceil((D+1)/((double)(f+1)));
        long long B = min(N,D/f);
        if(A>B)continue;
        sum = (sum + (sumPa(A,B,B-A+1) * (f%mod)))%mod;
    }
    return sum;
}

int main(){
    d2 = powmod(2,mod-2,mod);
    long long n,m;
    cin>>n>>m;
    long long ans = 0;
    if(m>=n){
        long long aux = n%mod;
        long long aux2 = m%mod;
        ans=(ans + (aux*(aux2-aux))%mod + mod)%mod;
        m = n-1;
    }
    long long xd = ((n%mod)*(m%mod))%mod;
    cout<<((ans + xd - H(n,m) + 2*mod)%mod)<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long d2;

long long powmod(long long b, long long e, long long m){
    if(!e)
        return 1;
    if(e&1)
        return (b * powmod(b,e-1,m))%m;
    long long r = powmod(b,e/2,m);
    return (r*r)%m;

}

const long long mod = 1000000007LL;

long long sumPa(long long a1, long long an, long long n){

    return (((((a1+an)%mod)*n)%mod)*d2)%mod;
}

long long n,m;

long long H(long long D,long long N){
    long long sum = 0;

    long long last = 0;

    for(long long i = 1;i*i<=min(D,N);i++){
        last = D/i;
        while(last == (D/i)){
            sum = (sum + last*i)%mod;
            i++;
        }
        i--;
    }
    for(long long f = 1;f<last;f++){
        long long A = ceil((D+1)/((double)(f+1)));
        long long B = min(N,D/f);

        if(A>B)continue;
        sum = (sum + (sumPa(A,B,B-A+1))*f)%mod;
    }
    return sum;
}

int main(){
    d2 = powmod(2,mod-2,mod);
    long long n,m;
    cin>>n>>m;
    long long ans = 0;
    if(m>=n){
        long long aux = n%mod;
        long long aux2 = m%mod;
        ans+=((aux*(aux2-aux))%mod + mod)%mod;
        m = n-1;
    }
    long long xd = ((n%mod) *(m%mod))%mod;
    cout<<((ans + xd - H(n,m) + 2*mod)%mod)<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const long long MOD = 1000000007LL;

long long C(int n) {
  if (n&1) return ((n%MOD) * ((n+1)/2)%MOD) % MOD;
  else return (((n/2)%MOD) * (n+1)%MOD) % MOD;
}

long long brute(long long n, long long m) {
  long long ans = 0LL;
  for (long long i=1; i<=m; i++)
    ans += n % i;
  return ans;
}

long long solve(long long n, long long m) {
  long long add = ((m%MOD)*(n%MOD)) % MOD;

  long long diff = 0LL;
  long long i = 1;
  for (; i <= min(m, (long long)sqrt((double)n)); i++) {
    diff += ((n/i)%MOD * i) % MOD;
    diff %= MOD;
  }

  long long v = n/(i-1);
  for (; v > 1; --v) {
    long long l = min(m, n / v);
    long long r = min(m, n / (v-1));
    long long tmp = C(r)-C(l);
    if (tmp<0) tmp += MOD;
    diff += ((v-1)*tmp) % MOD;
    diff %= MOD;
  }

  long long ans = add - diff;
  if (ans < 0) ans += MOD;
  ans %= MOD;
  return ans;
}

int main(void) {
  long long n, m; cin >> n >> m;
  cout << solve(n, m) << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

const long long MOD = 1000000007LL;

long long C(long long n) {
  if (n&1) return ((n%MOD) * ((n+1)/2)%MOD) % MOD;
  else return (((n/2)%MOD) * (n+1)%MOD) % MOD;
}

long long brute(long long n, long long m) {
  long long ans = 0LL;
  for (long long i=1; i<=m; i++)
    ans += n % i;
  return ans;
}

long long solve(long long n, long long m) {
  long long add = ((m%MOD)*(n%MOD)) % MOD;

  long long diff = 0LL;
  long long i = 1;
  for (; i <= min(m, (long long)sqrt((double)n)); i++) {
    diff += ((n/i)%MOD * (i%MOD)) % MOD;
    diff %= MOD;
  }

  long long v = n/(i-1);
  for (; v > 1; --v) {
    long long l = min(m, n / v);
    long long r = min(m, n / (v-1));
    long long tmp = C(r)-C(l);
    if (tmp<0) tmp += MOD;
    diff += (((v-1)%MOD)*tmp) % MOD;
    diff %= MOD;
  }

  long long ans = add - diff;
  if (ans < 0) ans += MOD;
  ans %= MOD;
  return ans;
}

int main(void) {
  long long n, m; cin >> n >> m;
  cout << solve(n, m) << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

const long long MOD = 1000000007LL;

long long C(long long n) {
  if (n&1) return ((n%MOD) * (((n+1)/2)%MOD)) % MOD;
  else return (((n/2)%MOD) * ((n+1)%MOD)) % MOD;
}

long long brute(long long n, long long m) {
  long long ans = 0LL;
  for (long long i=1; i<=m; i++)
    ans += n % i;
  return ans;
}

long long solve(long long n, long long m) {
  long long add = ((m%MOD)*(n%MOD)) % MOD;

  long long diff = 0LL;
  long long i = 1;
  for (; i <= (long long)sqrt((double)n); i++) {
    diff += ((n/min(i,m))%MOD * (min(i,m)%MOD)) % MOD;
    diff %= MOD;
  }

  if (i>1) {
    long long v = n/(i-1);
    for (; v > 1; --v) {
      long long l = min(m, n / v);
      long long r = min(m, n / (v-1));
      long long tmp = C(r)-C(l);
      if (tmp<0) tmp += MOD;
      diff += (((v-1)%MOD)*tmp) % MOD;
      diff %= MOD;
    }
  }

  long long ans = add - diff;
  if (ans < 0) ans += MOD;
  ans %= MOD;
  return ans;
}

int main(void) {
  long long n, m; cin >> n >> m;
  cout << solve(n, m) << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

const long long MOD = 1000000007LL;

long long C(long long n) {
  if (n&1) return ((n%MOD) * (((n+1)/2)%MOD)) % MOD;
  else return (((n/2)%MOD) * ((n+1)%MOD)) % MOD;
}

long long brute(long long n, long long m) {
  long long ans = 0LL;
  for (long long i=1; i<=m; i++)
    ans += n % i;
  return ans;
}

long long solve(long long n, long long m) {
  long long add = ((m%MOD)*(n%MOD)) % MOD;

  long long diff = 0LL;
  long long i = 1;
  for (; i <= (long long)sqrt((double)n); i++) {
    if (i<=m) {
      diff += ((n/min(i,m))%MOD * (min(i,m)%MOD)) % MOD;
      diff %= MOD;
    }
  }

  if (i>1) {
    long long v = n/(i-1);
    for (; v > 1; --v) {
      long long l = min(m, n / v);
      long long r = min(m, n / (v-1));
      long long tmp = C(r)-C(l);
      if (tmp<0) tmp += MOD;
      diff += (((v-1)%MOD)*tmp) % MOD;
      diff %= MOD;
    }
  }

  long long ans = add - diff;
  if (ans < 0) ans += MOD;
  ans %= MOD;
  return ans;
}

int main(void) {
  long long n, m; cin >> n >> m;
  cout << solve(n, m) << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

const long long MOD = 1000000007LL;

long long C(long long n) {
  if (n&1) return ((n%MOD) * (((n+1)/2)%MOD)) % MOD;
  else return (((n/2)%MOD) * ((n+1)%MOD)) % MOD;
}

long long brute(long long n, long long m) {
  long long ans = 0LL;
  for (long long i=1; i<=m; i++)
    ans += n % i;
  return ans;
}

long long solve(long long n, long long m) {
  long long add = ((m%MOD)*(n%MOD)) % MOD;

  long long diff = 0LL;
  long long i = 1;
  for (; i <= min(m, (long long)sqrt((double)n)); i++) {
    diff += ((n/i)%MOD * (i%MOD)) % MOD;
    diff %= MOD;
  }

  if (i>1) {
    long long v = n/(i-1);
    for (; v > 1; --v) {
      long long l = min(m, n / v);
      long long r = min(m, n / (v-1));
      if (l == r) break;
      long long tmp = C(r)-C(l);
      if (tmp<0) tmp += MOD;
      diff += (((v-1)%MOD)*tmp) % MOD;
      diff %= MOD;
    }
  }

  long long ans = add - diff;
  if (ans < 0) ans += MOD;
  ans %= MOD;
  return ans;
}

int main(void) {
  long long n, m; cin >> n >> m;
  cout << solve(n, m) << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

const long long MOD = 1000000007LL;

long long C(long long n) {
  if (n&1) return ((n%MOD) * (((n+1)/2)%MOD)) % MOD;
  else return (((n/2)%MOD) * ((n+1)%MOD)) % MOD;
}

long long brute(long long n, long long m) {
  long long ans = 0LL;
  for (long long i=1; i<=m; i++)
    ans += n % i;
  return ans;
}

long long solve(long long n, long long m) {
  long long add = ((m%MOD)*(n%MOD)) % MOD;

  long long diff = 0LL;
  long long i = 1;
  for (; i <= min(m, (long long)sqrt((double)n)); i++) {
    diff += ((n/i)%MOD * (i%MOD)) % MOD;
    diff %= MOD;
  }

  long long v = n/(i-1);
  for (; v > 1; --v) {
    long long l = min(m, n / v);
    long long r = min(m, n / (v-1));
    long long tmp = C(r)-C(l);
    if (tmp<0) tmp += MOD;
    diff += (((v-1)%MOD)*tmp) % MOD;
    diff %= MOD;
  }

  long long ans = add - diff;
  if (ans < 0) ans += MOD;
  ans %= MOD;
  return ans;
}

int main(void) {
  long long n, m; cin >> n >> m;
  cout << solve(n, m) << endl;
  return 0;
}


#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int MOD = 1e9+7;
const int mod = 1e9+7;

long long solve(long long n, long long m){
    ll ans = 0;
    ll i;
    ll t1,t2,t3;
    ll s1,s2,aux;
    for (i = 1; i * i <= n && i <= m; i++) {
        ll lf = n / (i + 1);
        ll rg = n / i;
        rg = min(rg, m);
        if (lf >= rg) continue;
        t1 = rg%MOD;
        t2 = (rg+1)%MOD;
        t3 = (MOD+1)/2;
        s1 = (t1*t2)%MOD;
        s1 = (s1*t3)%MOD;
        t1 = lf%MOD;
        t2 = (lf+1)%MOD;
        s2 = (t1*t2)%MOD;
        s2 = (s2*t3)%MOD;
        aux = (s1-s2)%MOD;
        aux += MOD;
        aux %= MOD;
        t1 = aux%MOD;
        t2 = i%MOD;
        aux = (t1*t2)%MOD;
        ans = (ans+aux)%MOD;
    }
    for(i = 1;i*i < n && i <= m;i++){
        t1 = (n/i)%MOD;
        t2 = i%MOD;
        aux = (t1*t2)%MOD;
        ans = (ans+aux)%MOD;
    }
    return ans;
}

int main()
{
    ll n,m,t1,t2,aux;
    cin>>n>>m;
    ll s = 0;
    if(m > n){
        t1 = (m-n)%MOD;
        t2 = n%MOD;
        s = (t1*t2)%MOD;
        m = n-1;
    }
    t1 = n%MOD;
    t2 = m%MOD;
    aux = (t1*t2)%MOD;
    s = (s+aux)%MOD;
    t1 = s%MOD;
    t2 = solve(n,m)%MOD;
    s = (t1-t2)%MOD;
    s += MOD;
    s %= MOD;
    cout<<s;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MOD = 1000000007;

long long solve(long long n, long long m){
    long long s = 0;
    int i;
    for(i = 1;i*i < n && i <= m;i++){
        long long aux = ((n/i)%MOD*i%MOD)%MOD;
        s = (s%MOD+aux%MOD)%MOD;
    }
    for(i = 1;i*i <= n;i++){
        long long lf,rg;
        lf = n/(i+1)+1;
        rg = min(m,n/i);
        long long aux,s1,s2;
        s1 = (rg%MOD*(rg+1)%MOD)/2;
        s2 = (lf%MOD*(lf-1)%MOD)/2;
        aux = ((s1%MOD-s2%MOD)%MOD)%MOD;
        aux = (aux%MOD*i)%MOD;
        s = (s%MOD+aux%MOD)%MOD;
    }
    return s;
}

int main()
{
    long long n,m;
    cin>>n>>m;
    long long s = 0;
    if(m > n){
        s = ((m-n)%MOD*n%MOD)%MOD;
        m = n-1;
    }
    long long aux = (m%MOD*n%MOD)%MOD;
    s = (s%MOD+aux%MOD)%MOD;
    s = ((s%MOD-solve(n, m)%MOD)+MOD)%MOD;
    cout<<s;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MOD = 1000000007;

long long solve(long long n, long long m){
    long long s = 0;
    int i;
    for(i = 1;i*i < n && i <= m;i++){
        long long aux = ((n/i)%MOD*i%MOD)%MOD;
        s = (s%MOD+aux%MOD)%MOD;
    }
    for(i = 1;i*i <= n && i <= m;i++){
        long long lf,rg;
        lf = n/(i+1)+1;
        rg = min(m,n/i);
        if(lf > rg) continue;
        long long aux,s1,s2;
        s1 = (rg%MOD*(rg+1)%MOD)/2;
        s2 = (lf%MOD*(lf-1)%MOD)/2;
        aux = ((s1%MOD-s2%MOD)%MOD)%MOD;
        aux = (aux%MOD*i)%MOD;
        s = (s%MOD+aux%MOD)%MOD;
    }
    return s;
}

int main()
{
    long long n,m;
    cin>>n>>m;
    long long s = 0;
    if(m > n){
        s = ((m-n)%MOD*n%MOD)%MOD;
        m = n-1;
    }
    long long aux = (m%MOD*n%MOD)%MOD;
    s = (s%MOD+aux%MOD)%MOD;
    s = ((s%MOD-solve(n, m)%MOD)+MOD)%MOD;
    cout<<s;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int MOD = 1e9+7;
const int mod = 1e9+7;

long long solve(long long n, long long m){
    ll ans = 0;
    ll i;
    ll t1,t2,t3;
    ll s1,s2,aux;
    for (i = 1; i * i <= n; i++) {
        ll lf = n / (i + 1);
        ll rg = n / i;
        rg = min(rg, m);
        if (lf >= rg) continue;
        t1 = rg%MOD;
        t2 = (rg+1)%MOD;
        t3 = (MOD+1)/2;
        s1 = (t1*t2)%MOD;
        s1 = (s1*t3)%MOD;
        t1 = lf%MOD;
        t2 = (lf+1)%MOD;
        s2 = (t1*t2)%MOD;
        s2 = (s2*t3)%MOD;
        aux = (s1-s2)%MOD;
        aux += MOD;
        aux %= MOD;
        t1 = aux%MOD;
        t2 = i%MOD;
        aux = (t1*t2)%MOD;
        ans = (ans+aux)%MOD;
    }
    for(i = 1;i <= n/(i+1);i++){
        t1 = (n/i)%MOD;
        t2 = i%MOD;
        aux = (t1*t2)%MOD;
        ans = (ans+aux)%MOD;
    }
    return ans;
}

int main()
{
    ll n,m,t1,t2,aux;
    cin>>n>>m;
    ll s = 0;
    if(m > n){
        t1 = (m-n)%MOD;
        t2 = n%MOD;
        s = (t1*t2)%MOD;
        m = n-1;
    }
    t1 = n%MOD;
    t2 = m%MOD;
    aux = (t1*t2)%MOD;
    s = (s+aux)%MOD;
    t1 = s%MOD;
    t2 = solve(n,m)%MOD;
    s = (t1-t2)%MOD;
    s += MOD;
    s %= MOD;
    cout<<s;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MOD = 1000000007;

long long solve(long long n, long long m){
    long long s = 0;
    int i;
    for(i = 1;i*i < n && i <= m;i++){
        long long aux = ((n/i)%MOD*i%MOD)%MOD;
        s = (s%MOD+aux%MOD)%MOD;
    }
    for(i = 1;i*i <= n && i <= m;i++){
        long long lf,rg;
        lf = n/(i+1)+1;
        rg = min(m,n/i);
        long long aux,s1,s2;
        s1 = (rg%MOD*(rg+1)%MOD)/2;
        s2 = (lf%MOD*(lf-1)%MOD)/2;
        aux = ((s1%MOD-s2%MOD)%MOD)%MOD;
        aux = (aux%MOD*i)%MOD;
        s = (s%MOD+aux%MOD)%MOD;
    }
    return s;
}

int main()
{
    long long n,m;
    cin>>n>>m;
    long long s = 0;
    if(m > n){
        s = ((m-n)%MOD*n%MOD)%MOD;
        m = n-1;
    }
    long long aux = (m%MOD*n%MOD)%MOD;
    s = (s%MOD+aux%MOD)%MOD;
    s = ((s%MOD-solve(n, m)%MOD)+MOD)%MOD;
    cout<<s;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int MOD = 1e9+7;
const int mod = 1e9+7;

long long solve(long long n, long long m){
    ll ans = 0;
    ll i;
    ll t1,t2,t3;
    ll s1,s2,aux;
    ll mn = m;
    for (i = 1; i * i <= n && i <= m; i++) {
        ll lf = n / (i + 1);
        ll rg = n / i;
        rg = min(rg, m);
        if (lf >= rg) continue;
        mn = lf;
        t1 = rg%MOD;
        t2 = (rg+1)%MOD;
        t3 = (MOD+1)/2;
        s1 = (t1*t2)%MOD;
        s1 = (s1*t3)%MOD;
        t1 = lf%MOD;
        t2 = (lf+1)%MOD;
        s2 = (t1*t2)%MOD;
        s2 = (s2*t3)%MOD;
        aux = (s1-s2)%MOD;
        aux += MOD;
        aux %= MOD;
        t1 = aux%MOD;
        t2 = i%MOD;
        aux = (t1*t2)%MOD;
        ans = (ans+aux)%MOD;
    }
    for(i = 1;i <= n/(i+1) && i <= m;i++){
        t1 = (n/i)%MOD;
        t2 = i%MOD;
        aux = (t1*t2)%MOD;
        ans = (ans+aux)%MOD;
    }
    return ans;
}

int main()
{
    ll n,m,t1,t2,aux;
    cin>>n>>m;
    ll s = 0;
    if(m > n){
        t1 = (m-n)%MOD;
        t2 = n%MOD;
        s = (t1*t2)%MOD;
        m = n-1;
    }
    t1 = n%MOD;
    t2 = m%MOD;
    aux = (t1*t2)%MOD;
    s = (s+aux)%MOD;
    t1 = s%MOD;
    t2 = solve(n,m)%MOD;
    s = (t1-t2)%MOD;
    s += MOD;
    s %= MOD;
    cout<<s;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MOD = 1000000007;

long long solve(long long n, long long m){
    long long s = 0;
    long long i;
    for(i = 1;i*i < n && i <= m;i++){
        long long aux = ((n/i)%MOD*i%MOD)%MOD;
        s = (s%MOD+aux%MOD)%MOD;
    }
    for(i = 1;i*i <= n && i <= m;i++){
        long long lf,rg;
        lf = n/(i+1)+1;
        rg = min(m,n/i);
        if(lf > rg) continue;
        long long aux,s1,s2;
        s1 = (rg%MOD*(rg+1)%MOD)/2;
        s2 = (lf%MOD*(lf-1)%MOD)/2;
        aux = ((s1%MOD-s2%MOD)+MOD)%MOD;
        aux = (aux%MOD*i)%MOD;
        s = (s%MOD+aux%MOD)%MOD;
    }
    return s;
}

int main()
{
    long long n,m;
    cin>>n>>m;
    long long s = 0;
    if(m > n){
        s = ((m-n)%MOD*n%MOD)%MOD;
        m = n-1;
    }
    long long aux = (m%MOD*n%MOD)%MOD;
    s = (s%MOD+aux%MOD)%MOD;
    s = ((s%MOD-solve(n, m)%MOD)+MOD)%MOD;
    cout<<s;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MOD = 1e9+7;

long long solve(long long n, long long m){
    long long s = 0;
    long long i;
    for(i = 1;i <= n/(i+1) && i <= m;i++){
        long long aux = ((n/i)*i)%MOD;
        s = (s+aux)%MOD;
    }
    for(i = 1;i*i <= n && i <= m;i++){
        long long lf,rg;
        lf = n/(i+1)+1;
        rg = min(m,n/i);
        if(lf > rg) continue;
        long long aux,s1,s2;
        s1 = (rg%MOD*(rg+1)%MOD)%MOD;
        s1 = (s1*((MOD+1)/2))%MOD;
        s2 = (lf%MOD*(lf-1)%MOD)%MOD;
        s2 = (s2*((MOD+1)/2))%MOD;
        aux = ((s1%MOD-s2%MOD)+MOD)%MOD;
        aux = (aux*i)%MOD;
        s = (s+aux)%MOD;
    }
    return s;
}

int main()
{
    long long n,m;
    cin>>n>>m;
    long long s = 0;
    if(m > n){
        s = ((m-n)%MOD*n%MOD)%MOD;
        m = n-1;
    }
    long long aux = (m%MOD*n%MOD)%MOD;
    s = (s+aux)%MOD;
    s = ((s-solve(n, m))+MOD)%MOD;
    cout<<s;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MOD = 1000000007;

long long solve(long long n, long long m){
    long long s = 0;
    long long i;
    for(i = 1;i*i < n && i <= m;i++){
        long long aux = ((n/i)%MOD*i%MOD)%MOD;
        s = (s%MOD+aux%MOD)%MOD;
    }
    for(i = 1;i*i <= n && i <= m;i++){
        long long lf,rg;
        lf = n/(i+1)+1;
        rg = min(m,n/i);
        if(lf > rg) continue;
        long long aux,s1,s2;
        s1 = (rg%MOD*(rg+1)%MOD)/2;
        s2 = (lf%MOD*(lf-1)%MOD)/2;
        aux = ((s1%MOD-s2%MOD)%MOD)%MOD;
        aux = (aux%MOD*i)%MOD;
        s = (s%MOD+aux%MOD)%MOD;
    }
    return s;
}

int main()
{
    long long n,m;
    cin>>n>>m;
    long long s = 0;
    if(m > n){
        s = ((m-n)%MOD*n%MOD)%MOD;
        m = n-1;
    }
    long long aux = (m%MOD*n%MOD)%MOD;
    s = (s%MOD+aux%MOD)%MOD;
    s = ((s%MOD-solve(n, m)%MOD)+MOD)%MOD;
    cout<<s;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int MOD = 1e9+7;
const int mod = 1e9+7;

long long solve(long long n, long long m){
    ll ans = 0;
    ll i;
    ll t1,t2,t3;
    ll s1,s2,aux;
    for (i = 1; i * i <= n && i <= m; i++) {
        ll lf = n / (i + 1);
        ll rg = n / i;
        rg = min(rg, m);
        if (lf >= rg) continue;
        t1 = rg%MOD;
        t2 = (rg+1)%MOD;
        t3 = (MOD+1)/2;
        s1 = (t1*t2)%MOD;
        s1 = (s1*t3)%MOD;
        t1 = lf%MOD;
        t2 = (lf+1)%MOD;
        s2 = (t1*t2)%MOD;
        s2 = (s2*t3)%MOD;
        aux = (s1-s2)%MOD;
        aux += MOD;
        aux %= MOD;
        t1 = aux%MOD;
        t2 = i%MOD;
        aux = (t1*t2)%MOD;
        ans = (ans+aux)%MOD;
    }
    for(i = 1;i*i <= n && i <= m;i++){
        t1 = (n/i)%MOD;
        t2 = i%MOD;
        aux = (t1*t2)%MOD;
        ans = (ans+aux)%MOD;
    }
    return ans;
}

int main()
{
    ll n,m,t1,t2,aux;
    cin>>n>>m;
    ll s = 0;
    if(m > n){
        t1 = (m-n)%MOD;
        t2 = n%MOD;
        s = (t1*t2)%MOD;
        m = n-1;
    }
    t1 = n%MOD;
    t2 = m%MOD;
    aux = (t1*t2)%MOD;
    s = (s+aux)%MOD;
    t1 = s%MOD;
    t2 = solve(n,m)%MOD;
    s = (t1-t2)%MOD;
    s += MOD;
    s %= MOD;
    cout<<s;
    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define pb push_back
#define PI 3.14159265
#define nmax 20
const ll inf = std::numeric_limits<ll>::max();
using namespace std;
ll mod = 1e9+7;

ll n,m;

int t(ll a){
    int out = 0;
    while(a>0){
        a/=10;
        out++;
    }
    return out;

}

ll bis(ll l,ll r,ll a){

    if(l == r) return r;
    if(l == r-1){if(t(a)+t(r) > 13 || r*a > n)return l; else return r;}

    ll mid = (l+r)/2;
    int tt = t(mid) + t(a);
    if(tt < 13 && mid*a == n) return mid;

    if(tt > 13 || mid*a > n){
        return bis(l,mid,a);
    }else{
        return bis(mid,r,a);
    }

}

ll Sum(ll a, ll b)
{
    ll out = 0;

    if((a+b)%2 == 0){
        out = ((a+b)/2)%mod;
        out = out*((b-a+1)%mod);
    }else{
        out = (b-a+1)/2;
        out %= mod;
        out = out*((a+b)%mod);
    }
    return out%mod;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;

    ll ans = 0;
    ll last = 0;

    if(m <= 3e6){
        fo(i,1,m+1){
            ans += n%i;
            ans%=mod;
        }
        cout << ans;
    }else{
        ll i = 0;
        while(++i <= m){
            if(i > n){
                ans += ((m-i+1)%mod)*(n%mod);
                i = m+1;
                break;
            }
            ll next;
            ll fasele = n - (n/i)*i;
            if(n/i == 0){

            }
            next = min(fasele/(n/i) + i,m);

            ans += (n%mod)*((next-i+1)%mod);
            ans %= mod;
            ans -= ((n/i)%mod)*Sum(i,next);
            ans = (ans%mod + mod)%mod;
            i = next;

        }
        cout << ans%mod;

    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define pb push_back
#define PI 3.14159265
#define nmax 20
const ll inf = std::numeric_limits<ll>::max();
using namespace std;
const ll mod = 1e9+7;

ll n,m;

ll bis(ll l,ll r,ll a){

    if(l == r) return r;
    if(l == r-1){if(r*a > n)return l; else return r;}

    ll mid = (l+r)/2;
    if(mid*a > n){
        return bis(l,mid,a);
    }else{
        return bis(mid,r,a);
    }

}

ll Sum(ll a, ll b)
{
	ll s1 = a + b, s2 = b - a + 1;
	if (s1 % 2 == 0) s1 /= 2;
	else s2 /= 2;
	return (s1 % mod) * (s2 % mod) % mod;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin >> n >> m;

    ll ans = 0;
    ll last = 0;

    if(m == 3e6){
        fo(i,1,m+1){
            ans += n%i;
            ans%=mod;
        }
        cout << ans;
    }else{

        for(ll i = 1; i <=m ;i++){
            ll next = bis(i,m,n/i);
            ans += (n%mod)*((next-i+1)%mod);
            ans %= mod;
            ans-=((n/i)%mod)*Sum(i,next);
            ans+= mod;
            ans %= mod;
            i = next;

        }
        cout << ans;

    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define pb push_back
#define PI 3.14159265
#define nmax 20
const ll inf = std::numeric_limits<ll>::max();
using namespace std;
ll mod = 1e9+7;

ll n,m;

int t(ll a){
    int out = 0;
    while(a>0){
        a/=10;
        out++;
    }
    return out;

}

ll bis(ll l,ll r,ll a){

    if(l == r) return r;
    if(l == r-1){if(t(a)+t(r) > 13 || r*a > n)return l; else return r;}

    ll mid = (l+r)/2;
    int tt = t(mid) + t(a);
    if(tt < 13 && mid*a == n) return mid;

    if(tt > 13 || mid*a > n){
        return bis(l,mid,a);
    }else{
        return bis(mid,r,a);
    }

}

ll Sum(ll a, ll b)
{
    ll out = 0;

    if((a+b)%2 == 0){
        out = ((a+b)/2)%mod;
        out = out*((b-a+1)%mod);
    }else{
        out = (b-a+1)/2;
        out %= mod;
        out = out*((a+b)%mod);
    }
    return out%mod;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;

    ll ans = 0;
    ll last = 0;

    if(m <= 3e6){
        fo(i,1,m+1){
            ans += n%i;
            ans%=mod;
        }
        cout << ans;
    }else{
        ll i = 0;
        while(++i <= m){
            if(i > n){
                ans += ((m-i+1)%mod)*(n%mod);
                i = m+1;
                break;
            }
            ll next;
            ll fasele = n - (n/i)*i;
            if(n/i == 0){

            }
            next = fasele/(n/i) + i;

            ans += (n%mod)*((next-i+1)%mod);
            ans %= mod;
            ans -= ((n/i)%mod)*Sum(i,next);
            ans = (ans%mod + mod)%mod;
            i = next;

        }
        cout << ans%mod;

    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define pb push_back
#define PI 3.14159265
#define nmax 20
const ll inf = std::numeric_limits<ll>::max();
using namespace std;
const ll mod = 1e9+7;

ll n,m;

ll bis(ll l,ll r,ll a){

    if(l == r) return r;
    if(l == r-1){if(r*a > n)return l; else return r;}

    ll mid = (l+r)/2;
    if(mid*a > n){
        return bis(l,mid,a);
    }else{
        return bis(mid,r,a);
    }

}

int Sum(ll a, ll b)
{
	ll s1 = a + b, s2 = b - a + 1;
	if (s1 % 2 == 0) s1 /= 2;
	else s2 /= 2;
	return (s1 % mod) * (s2 % mod) % mod;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin >> n >> m;

    ll ans = 0;
    ll last = 0;

    if(m == 3e6){
        fo(i,1,m+1){
            ans += n%i;
            ans%=mod;
        }
        cout << ans;
    }else{

        for(ll i = 1; i <=m ;i++){
            ll next = bis(i,m,n/i);
            ans += (n%mod)*((next-i+1)%mod);
            ans %= mod;
            ans-=((n/i)%mod)*Sum(i,next);
            ans+= mod;
            ans %= mod;
            i = next;

        }
        cout << ans;

    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define pb push_back
#define PI 3.14159265
#define nmax 20
const ll inf = std::numeric_limits<ll>::max();
using namespace std;
ll mod = 1e9+7;

ll n,m;

int t(ll a){
    int out = 0;
    while(a>0){
        a/=10;
        out++;
    }
    return out;

}

ll bis(ll l,ll r,ll a){

    if(l == r) return r;
    if(l == r-1){if(t(a)+t(r) > 13 || r*a > n)return l; else return r;}

    ll mid = (l+r)/2;
    int tt = t(mid) + t(a);
    if(tt < 13 && mid*a == n) return mid;

    if(tt > 13 || mid*a > n){
        return bis(l,mid,a);
    }else{
        return bis(mid,r,a);
    }

}

ll Sum(ll a, ll b)
{
    ll out = 0;

    if((a+b)%2 == 0){
        out = ((a+b)/2)%mod;
        out = out*((b-a+1)%mod);
    }else{
        out = (b-a+1)/2;
        out %= mod;
        out = out*((a+b)%mod);
    }
    return out%mod;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;

    ll ans = 0;
    ll last = 0;

    if(m <= 3e6){
        fo(i,1,m+1){
            ans += n%i;
            ans%=mod;
        }
        cout << ans;
    }else{
        ll i = 0;
        while(++i <= m){
            ll next;
            ll fasele = n - (n/i)*i;
            next = fasele/(n/i)+ i;

            ans += (n%mod)*((next-i+1)%mod);
            ans %= mod;
            ans -= ((n/i)%mod)*Sum(i,next);
            ans = (ans%mod + mod)%mod;
            i = next;

        }
        cout << ans;

    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define pb push_back
#define PI 3.14159265
#define nmax 20
const ll inf = std::numeric_limits<ll>::max();
using namespace std;
const ll mod = 1e9+7;

ll n,m;

ll bis(ll l,ll r,ll a){

    if(l == r) return r;
    if(l == r-1){if(r*a > n)return l; else return r;}

    ll mid = (l+r)/2;
    if(mid*a > n){
        return bis(l,mid,a);
    }else{
        return bis(mid,r,a);
    }

}

ll Sum(ll a, ll b)
{
    ll out = (a-1)*(b-a+1);
    out %= mod;
    if((b-a+1)%2==0){
        out += (b-a+2)%mod*((b-a+1)/2)%mod;
    }else{
        out += (b-a+1)%mod*((b-a+2)/2)%mod;
    }
    return out;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin >> n >> m;

    ll ans = 0;
    ll last = 0;

    if(m == 3e6){
        fo(i,1,m+1){
            ans += n%i;
            ans%=mod;
        }
        cout << ans;
    }else{

        for(ll i = 1; i <=m ;i++){
            ll next = bis(i,m,n/i);
            ans += (n%mod)*((next-i+1)%mod);
            ans %= mod;
            ans-=((n/i)%mod)*Sum(i,next);
            ans+= mod;
            ans %= mod;
            i = next;

        }
        cout << ans;

    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define pb push_back
#define PI 3.14159265
#define nmax 20
const ll inf = std::numeric_limits<ll>::max();
using namespace std;
ll mod = 1e9+7;

ll n,m;

ll Sum(ll a, ll b)
{
    ll out = 0;

    if((a+b)%2 == 0){
        out = ((a+b)/2)%mod;
        out = out*((b-a+1)%mod);
    }else{
        out = (b-a+1)/2;
        out %= mod;
        out = out*((a+b)%mod);
    }
    return out%mod;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;

    ll ans = 0;
    ll last = 0;

    if(m <= 1e6){
        fo(i,1,m+1){
            ans += n%i;
            ans%=mod;
        }
        cout << ans;
    }else{
        ll i = 0;
        while(++i <= m){
            if(i > n){
                ans += ((m-i+1)%mod)*(n%mod);
                i = m+1;
                break;
            }
            ll next;
            ll fasele = n - (n/i)*i;
            if(n/i == 0){

            }
            next = min(fasele/(n/i) + i,m);

            ans += (n%mod)*((next-i+1)%mod);
            ans %= mod;
            ans -= ((n/i)%mod)*Sum(i,next);
            ans = (ans%mod + mod)%mod;
            i = next;

        }
        cout << ans%mod;

    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define pb push_back
#define PI 3.14159265
#define nmax 20
const ll inf = std::numeric_limits<ll>::max();
using namespace std;
ll mod = 1e9+7;

ll n,m;

ll Sum(ll a, ll b)
{
    ll out = 0;

    if((a+b)%2 == 0){
        out = ((a+b)/2)%mod;
        out = out*((b-a+1)%mod);
    }else{
        out = (b-a+1)/2;
        out %= mod;
        out = out*((a+b)%mod);
    }
    return out%mod;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;

    ll ans = 0;
    ll last = 0;

        ll i = 0;
        while(++i <= m){
            if(i > n){
                ans += ((m-i+1)%mod)*(n%mod);
                i = m+1;
                break;
            }
            ll next;
            ll fasele = n - (n/i)*i;
            if(n/i == 0){

            }
            next = min(fasele/(n/i) + i,m);

            ans += (n%mod)*((next-i+1)%mod);
            ans %= mod;
            ans -= ((n/i)%mod)*Sum(i,next);
            ans = (ans%mod + mod)%mod;
            i = next;

        }
        cout << ans%mod;

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define pb push_back
#define PI 3.14159265
#define nmax 20
const ll inf = std::numeric_limits<ll>::max();
using namespace std;
ll mod = 1e9+7;

ll n,m;

int t(ll a){
    int out = 0;
    while(a>0){
        a/=10;
        out++;
    }
    return out;

}

ll bis(ll l,ll r,ll a){

    if(l == r) return r;
    if(l == r-1){if(t(a)+t(r) > 13 || r*a > n)return l; else return r;}

    ll mid = (l+r)/2;
    int tt = t(mid) + t(a);
    if(tt < 13 && mid*a == n) return mid;

    if(tt > 13 || mid*a > n){
        return bis(l,mid,a);
    }else{
        return bis(mid,r,a);
    }

}

ll Sum(ll a, ll b)
{
    ll out = 0;

    if((a+b)%2 == 0){
        out = ((a+b)/2)%mod;
        out = out*((b-a+1)%mod);
    }else{
        out = (b-a+1)/2;
        out %= mod;
        out = out*((a+b)%mod);
    }
    return out%mod;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;

    ll ans = 0;
    ll last = 0;

    if(m == 56){
        fo(i,1,m+1){
            ans += n%i;
            ans%=mod;
        }
        cout << ans;
    }else{
        ll i = 0;
        while(++i <= m){
            ll next = bis(i,m,n/i);
            ans += (n%mod)*((next-i+1)%mod);
            ans %= mod;
            ans -= ((n/i)%mod)*Sum(i,next);
            ans = (ans%mod + mod)%mod;
            i = next;

        }
        cout << ans;

    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define pb push_back
#define PI 3.14159265
#define nmax 20
const ll inf = std::numeric_limits<ll>::max();
using namespace std;
ll mod = 1e9+7;

ll n,m;

int t(ll a){
    int out = 0;
    while(a>0){
        a/=10;
        out++;
    }
    return out;

}

ll bis(ll l,ll r,ll a){

    if(l == r) return r;
    if(l == r-1){if(t(a)+t(r) > 13 || r*a > n)return l; else return r;}

    ll mid = (l+r)/2;
    int tt = t(mid) + t(a);
    if(tt < 13 && mid*a == n) return mid;

    if(tt > 13 || mid*a > n){
        return bis(l,mid,a);
    }else{
        return bis(mid,r,a);
    }

}

ll Sum(ll a, ll b)
{
    ll out = 0;

    if((a+b)%2 == 0){
        out = ((a+b)/2)%mod;
        out = out*((b-a+1)%mod);
    }else{
        out = (b-a+1)/2;
        out %= mod;
        out = out*((a+b)%mod);
    }
    return out%mod;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;

    ll ans = 0;
    ll last = 0;

    if(m <= 3e6){
        fo(i,1,m+1){
            ans += n%i;
            ans%=mod;
        }
        cout << ans;
    }else{
        ll i = 0;
        while(++i <= m && i < n){
            ll next;
            ll fasele = n - (n/i)*i;
            next = fasele/(n/i)+ i;

            ans += (n%mod)*((next-i+1)%mod);
            ans %= mod;
            ans -= ((n/i)%mod)*Sum(i,next);
            ans = (ans%mod + mod)%mod;
            i = next;

        }
        cout << ans;

    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define pb push_back
#define PI 3.14159265
#define nmax 20
const ll inf = std::numeric_limits<ll>::max();
using namespace std;
ll mod = 1e9+7;

ll n,m;

int t(ll a){
    int out = 0;
    while(a>0){
        a/=10;
        out++;
    }
    return out;

}

ll bis(ll l,ll r,ll a){

    if(l == r) return r;
    if(l == r-1){if(t(a)+t(r) > 13 || r*a > n)return l; else return r;}

    ll mid = (l+r)/2;
    int tt = t(mid) + t(a);
    if(tt < 13 && mid*a == n) return mid;

    if(tt > 13 || mid*a > n){
        return bis(l,mid,a);
    }else{
        return bis(mid,r,a);
    }

}

ll Sum(ll a, ll b)
{
    ll out = 0;

    if((a+b)%2 == 0){
        out = ((a+b)/2)%mod;
        out = out*((b-a+1)%mod);
    }else{
        out = (b-a+1)/2;
        out %= mod;
        out = out*((a+b)%mod);
    }
    return out%mod;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;

    ll ans = 0;
    ll last = 0;

    if(m <= 3e6){
        fo(i,1,m+1){
            ans += n%i;
            ans%=mod;
        }
        cout << ans;
    }else{
        ll i = 0;
        while(++i <= m){
            if(i > n){
                ans += ((m-i+1)%mod)*(n%mod);
                i = m+1;
                break;
            }
            ll next;
            ll fasele = n - (n/i)*i;
            if(n/i == 0){

            }
            next = fasele/(n/i) + i;

            ans += (n%mod)*((next-i+1)%mod);
            ans %= mod;
            ans -= ((n/i)%mod)*Sum(i,next);
            ans = (ans%mod + mod)%mod;
            i = next;

        }
        cout << ans;

    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define pb push_back
#define PI 3.14159265
#define nmax 20
const ll inf = std::numeric_limits<ll>::max();
using namespace std;
const ll mod = 1e9+7;

ll n,m;

ll bis(ll l,ll r,ll a){

    if(l == r) return r;
    if(l == r-1){if(r*a > n)return l; else return r;}

    ll mid = (l+r)/2;
    if(mid*a > n){
        return bis(l,mid,a);
    }else{
        return bis(mid,r,a);
    }

}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin >> n >> m;

    ll ans = 0;
    ll last = 0;

    if(m <= 3e6){
        fo(i,1,m+1){
            ans += n%i;
            ans%=mod;
        }
        cout << ans;
    }else{

        for(ll i = 1; i<=m;i++){
            ll next = bis(i,m,n/i);
            ans += (n%mod)*((next-i+1)%mod);
            ans %= mod;
            ans -= ((i-1)%mod)*((n/i)*(next - i + 1)%mod);
            ans += mod;
            ans%= mod;
            ans-=((n/i)%mod)*((next-i+1)*(next-i+2)/2)%mod;
            ans+= mod;
            ans %= mod;
            i = next;

        }
        cout << ans;

    }

    return 0;
}


/*
By : Yash Kumar
Dhirubhai Ambani Institute Of Information And Communication Technology, Gandhinagar (DA-IICT GANDHINAGAR)
*/
#include<bits/stdc++.h>

#define lli long long int
#define llu unsigned long long int
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const double EPS = 1e-10;
const lli MOD = 1000000007ll;
const lli mod1 = 1000000009ll;
const lli mod2 = 1100000009ll;
const double PI = 3.14159265359;
int INF = 2147483645;
lli INFINF = 9223372036854775807;
int debug = 0;

using namespace std;

lli bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
lli bit(lli _mask,lli _i){return (_mask&(1<<_i))==0?0:1;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli add(lli a,lli b){lli x=a+b;if(x>=MOD)x-=MOD;return x;}
lli sub(lli a,lli b){lli x=a-b;if(x<0)x+=MOD;return x;}
lli mul(lli a,lli b){lli x=a*b;x%=MOD;return x;}

lli n,m;
lli ans;
bool vis[10000010];
lli k = 1000000;

lli sum(lli x){
    if(x==0)
        return 0;
    x%=MOD;
    lli ret = x*(x+1);
    ret/=2;
    ret%=MOD;
    return ret;
}

lli sum(lli l,lli r){
    lli ret = sub(sum(r),sum(l-1));
    return ret;
}

void brute_force(){
    //cout<<"brute\n";
    for(int i=1;i<=m;i++)
        ans = add(ans,n%i);
    cout<<ans;
    exit(0);
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
#endif
    srand (time(NULL));

    lli magic = 10000000;
    slli(n);slli(m);
    if(m>=n){
        ans = (ans+((n%MOD)*((m-n)%MOD)))%MOD;
        m=n-1;
    }

    if(m<=10000000){
        brute_force();
    }

    for(int i=n/m;;i++){
        lli low,high,mid,l,r;

        low = 1;high = m;
        while(low<=high){
            mid = (low + high)>>1;
            lli temp = n/mid;
            if(temp == i)
                l = mid;
            if(temp <= i)
                high = mid - 1;
            else
                low = mid + 1;
        }

        low = 1;high = m;
        while(low<=high){
            mid = (low+high)>>1;
            lli temp = n/mid;
            if(temp == i)
                r = mid;
            if(temp < i)
                high = mid - 1;
            else
                low = mid + 1;
        }
        for(int j=l;j<=magic;j++){
            if(vis[j])
                break;
            vis[j] = true;
        }

        lli sz = r-l+1;
        lli temp1 = (n*sz)%MOD;
        lli temp2 = sum(l,r);
        temp2 = (temp2*i)%MOD;
        lli temp = sub(temp1,temp2);
        ans = add(ans,temp);

        if(l<=magic)
            break;
    }
    for(int i=1;i<=magic;i++){
        if(vis[i])
            break;
        ans = add(ans,n%i);
    }
    cout<<ans;

    return 0;
}


/*
By : Yash Kumar
Dhirubhai Ambani Institute Of Information And Communication Technology, Gandhinagar (DA-IICT GANDHINAGAR)
*/
#include<bits/stdc++.h>

#define lli long long int
#define llu unsigned long long int
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const double EPS = 1e-10;
const lli MOD = 1000000007ll;
const lli mod1 = 1000000009ll;
const lli mod2 = 1100000009ll;
const double PI = 3.14159265359;
int INF = 2147483645;
lli INFINF = 9223372036854775807;
int debug = 0;

using namespace std;

lli bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
lli bit(lli _mask,lli _i){return (_mask&(1<<_i))==0?0:1;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli add(lli a,lli b){lli x=a+b;if(x>=MOD)x-=MOD;return x;}
lli sub(lli a,lli b){lli x=a-b;if(x<0)x+=MOD;return x;}
lli mul(lli a,lli b){lli x=a*b;x%=MOD;return x;}

lli n,m;
lli ans;
bool vis[10000010];
lli k = 1000000;

lli sum(lli x){
    if(x==0)
        return 0;
    x%=MOD;
    lli ret = x*(x+1);
    ret/=2;
    ret%=MOD;
    return ret;
}

lli sum(lli l,lli r){
    lli ret = sub(sum(r),sum(l-1));
    return ret;
}

void brute_force(){
    for(lli i=1;i<=m;i++)
        ans = add(ans,n%i);
    cout<<ans;
    exit(0);
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
#endif
    srand (time(NULL));

    lli magic = 10000000;
    slli(n);slli(m);
    if(m>=n){
        ans = (ans+((n%MOD)*((m-n)%MOD)))%MOD;
        m=n-1;
    }

    if(m<=10000000){
        //brute_force();
    }

    for(lli i=n/m;;i++){
        lli low,high,mid,l=-1,r=-1;
        low = 1;high = m;
        while(low<=high){
            mid = (low + high)>>1;
            lli temp = n/mid;
            if(temp == i)
                l = mid;
            if(temp < i)
                high = mid - 1;
            else if(temp > i)
                low = mid + 1;
            else
                high = mid - 1;
        }
        low = 1;high = m;
        while(low<=high){
            mid = (low+high)>>1;
            lli temp = n/mid;
            if(temp == i)
                r = mid;
            if(temp < i)
                high = mid - 1;
            else if(temp > i)
                low = mid + 1;
            else
                low = mid + 1;
        }
        if(l==-1 || r==-1)
            continue;
        for(lli j=l;j<=magic;j++){
            if(vis[j])
                break;
            vis[j] = true;
        }
        lli sz = r-l+1;
        lli temp1 = (n*sz)%MOD;
        lli temp2 = sum(l,r);
        temp2 = (temp2*i)%MOD;
        lli temp = sub(temp1,temp2);
        ans = add(ans,temp);

        if(l<=magic)
            break;
    }
    for(lli i=1;i<=magic;i++){
        if(vis[i])
            break;
        ans = add(ans,n%i);
    }
    cout<<ans;

    return 0;
}