import java.util.Scanner;

public class Main
{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		char[] str = sc.next().toCharArray();

		int alpha[][] = new int[n][26];

		for(int i = n - 2; i >= 0; i--){
			for(int j = 0; j < 26; j++){
				alpha[i][j] = alpha[i + 1][j];
			}

			alpha[i][str[i + 1] - 'a']++;
		}

		//debug
//		for(int i = 0; i < 26; i++){
//			for(int j = 0; j < n; j++){
//				System.out.print(alpha[j][i]+" ");
//			}
//			System.out.println();
//		}

		long result = 0;
		int mod = 1_000_000_007;
		for(int i = 0; i < n; i++){
			long tmp = 1;

			for(int j = 0; j < 26; j++){
				if(alpha[i][j] == 0 || j == str[i] - 'a'){
					continue;
				}

				tmp *= (alpha[i][j] + 1);
				tmp %= mod;
			}

			result += tmp;
		}

		System.out.println(result);
	}
}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		char[] str = sc.next().toCharArray();

		int alpha[][] = new int[n][26];

		for(int i = n - 2; i >= 0; i--){
			for(int j = 0; j < 26; j++){
				alpha[i][j] = alpha[i + 1][j];
			}

			alpha[i][str[i + 1] - 'a']++;
		}

		//debug
//		for(int i = 0; i < 26; i++){
//			for(int j = 0; j < n; j++){
//				System.out.print(alpha[j][i]+" ");
//			}
//			System.out.println();
//		}

		long result = 0;
		int mod = 1_000_000_007;
		for(int i = 0; i < n; i++){
			long tmp = 1;

			for(int j = 0; j < n; j++){
				if(alpha[i][j] == 0 || j == str[i] - 'a'){
					continue;
				}

				tmp *= (alpha[i][j] + 1);
				tmp %= mod;
			}

			result += tmp;
		}

		System.out.println(result);
	}
}


#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100010
#define MO 1000000007
#define LL long long
int n,cnt[26];
char s[MAXN];
int main()
{
	scanf("%d%s",&n,s);
	for(int i=0;i<n;i++) cnt[s[i]-'a']++;
	LL t1=0,t2=0;
	for(int i=0;i<8192;i++)
	{
		LL tmp1=1,tmp2=1;
		for(int j=0;j<13;j++)
			if((i>>j)&1) (tmp1*=cnt[j])%=MO,(tmp2*=cnt[j+13])%=MO;
		(t1+=tmp1)%=MO;(t2+=tmp2)%=MO;
	}
	t1=(t1*t2%MO-1+MO)%MO;
	printf("%lld\n",t1);
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=100005;
const int mod=1e9+7;
char s[N];
int cnt[26];
int n;
int main()
{
    scanf("%d",&n);
    scanf("%s",s+1);
    for(int i=1;i<=n;i++)
		cnt[s[i]-'a']++;
	int ans=1;
    for(int i=0;i<26;i++)
		ans=1ll*ans*(cnt[i]+1)%mod;
    ans=(ans-1+mod)%mod;
    printf("%d\n",ans);
}


#include <stdio.h>
int main(void){
    int d;
    scanf("%d",&d);
    int a[30];
    for(int i=0;i<30;i++)a[i]=0;
    char c[100005];
    scanf("%s",c);
    for(int i=0;i<d;i++){
        a[c[i]-'a']++;
    }
    long long p=1000000007;
    long long ans=1;
    for(int i=0;i<26;i++){
        ans*=a[i]+1;
        ans%=p;
    }
    printf("%lld\n",(ans-1+p)%p);
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;

    vector <int> table(26,1);

    rep(i,n){
        char tmp = s[i];
        int tmp1 = tmp - 97;
        table[tmp1] ++;
    }

    long long ans = 1;
    rep(i,26){
        ans *= table[i];
    }
    ans --;

    cout << ans << endl;

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
// const ll INF = 1000000000000000000LL;

  const int MAX = 510000;

  ll fac[MAX], finv[MAX], inv[MAX];

  // テーブルを作る前処理
  //ここO(n)
  void COMinit() {
      fac[0] = fac[1] = 1;
      finv[0] = finv[1] = 1;
      inv[1] = 1;
      for (int i = 2; i < MAX; i++){
          fac[i] = fac[i - 1] * i % MOD;
          //すごいことしてO(1)で求めてる
          inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
          finv[i] = finv[i - 1] * inv[i] % MOD;
      }
  }

  // 二項係数計算
  ll COM(int n, int k){
      if (n < k) return 0;
      if (n < 0 || k < 0) return 0;
      return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
  }

int main() {
    int n;
    string s;
    cin >> n >> s;
    //重複を調べる
    vector<int> table(26);
    rep(i,n){
        table[s[i]-'a']++;
    }
    COMinit();
    ll all = 0;
    for(int i=1;i<=n;i++){
        all += COM(n,i);
        all %= MOD;
    }
    // cout << all << endl;
    int sum=0;
    int cnt = 0;
    rep(i,26){
        ll cur = 0;
        ll mu = 0;
        if(table[i]>1){
            cnt++;
            for(int j=0;j<=n-table[i];j++){
                cur += COM(n-table[i],j);
                cur %= MOD;
            }
            for(int j=2;j<=table[i];j++){
                mu+=COM(table[i],j);
                mu %= MOD;
            }
            sum+=table[i];
        }
        // cout << cur << endl;
        // cout << mu << endl;
        cur *= mu;
        cur %=MOD;
        all -= cur;
        if(all<0)
            all+=MOD;
    }
    int add = 0;
    if(cnt>1){
        for(int i=0;i<=n-sum;i++){
            add += COM(n-sum,i);
            add %= MOD;
        }
    }
    all+=add;
    if(add>MOD)
        add %= MOD;
    cout << all << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
// const ll INF = 1000000000000000000LL;

  const int MAX = 510000;

  ll fac[MAX], finv[MAX], inv[MAX];

  // テーブルを作る前処理
  //ここO(n)
  void COMinit() {
      fac[0] = fac[1] = 1;
      finv[0] = finv[1] = 1;
      inv[1] = 1;
      for (int i = 2; i < MAX; i++){
          fac[i] = fac[i - 1] * i % MOD;
          //すごいことしてO(1)で求めてる
          inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
          finv[i] = finv[i - 1] * inv[i] % MOD;
      }
  }

  // 二項係数計算
  ll COM(int n, int k){
      if (n < k) return 0;
      if (n < 0 || k < 0) return 0;
      return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
  }

int main() {
    int n;
    string s;
    cin >> n >> s;
    //重複を調べる
    vector<int> table(26);
    rep(i,n){
        table[s[i]-'a']++;
    }
    COMinit();
    ll all = 0;
    for(int i=1;i<=n;i++){
        all += COM(n,i);
        all %= MOD;
    }
    // cout << all << endl;
    int sum=0;
    int cnt = 0;
    rep(i,26){
        ll cur = 0;
        if(table[i]>1){
            cnt++;
            for(int j=0;j<=n-table[i];j++){
                cur += COM(n-table[i],j);
                cur %= MOD;
            }
            sum+=table[i];
        }
        all -= cur;
        if(all<0)
            all+=MOD;
    }
    int add = 0;
    if(cnt>1){
        for(int i=0;i<=n-sum;i++){
            add += COM(n-sum,i);
            add %= MOD;
        }
    }
    all+=add;
    if(add>MOD)
        add %= MOD;
    cout << all << endl;
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
	int N;
	char S[100001];
	scanf("%d", &N);
	scanf("%s", S);

	int i, count[26] = {};
	long long total = 1;
	for (i = 0; S[i] != 0; i++) count[S[i] - 'a']++;
	for (i = 0; i < 26; i++) total = total * (count[i] + 1) % 1000000007;

	printf("%lld\n", (total + 1000000006) % 1000000007);
	fflush(stdout);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define N 100009
#define MOD 1000000007
int acs(const void* a, const void* b) { return *(int*)a - *(int*)b; }//1,2,3,4
int des(const void* a, const void* b) { return *(int*)b - *(int*)a; }//8,7,6,5
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; }//a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); }//aaa,aab
//temmie_のsnippet

int main() {
	int a[27],n;char s[N];LL ans=1;
	rep(i,26)a[i]=1;
	scanf("%d%s",&n,s);
	rep(i,n)a[s[i]-97]++;
	rep(i,26){ans*=a[i];ans%=MOD;}
	printf("%lld",ans-1);
	return 0;
}


#include <stdio.h>

#define MOD 1000000007

int main()
{
    int n,bucket[26] = {0},i,j;
    char s[100001];

    scanf("%d %s",&n,s);
    for (i = 0; i < n; i++)
    {
        bucket[s[i] - 'a']++;
    }

    long long ans = 1;

    for (i = 0; i < 26; i++)
    {
        ans *= bucket[i] + 1;
        ans %= MOD;
    }

    printf("%lld",ans - 1);
}


#include<stdio.h>

#define MOD 1000000007

int mod_multi(int a,int b){
    long long int ret;
    ret = a*b;
    if(ret>MOD)ret %= MOD;
    return ret;
}

int main(void){
    int n;
    scanf("%d",&n);
    char str[n];
    scanf("%s",str);
    int ans = 1;
    int cc[26] = {};
    for(int i = 0;i < n;i++)cc[str[i]-'a']++;
    for(int i = 0;i < 26;i++)ans = mod_multi(ans,cc[i]+1);
    printf("%d",ans-1);
    return 0;
}


#include<stdio.h>

int main(void){
  char S[100001];
  int n;
  long long int ans = 1,mod = 1000000007,c[26] = {0};

  scanf("%d",&n);
  scanf("%s",S);

  for(int i = 0;i<n;i++){
    c[S[i] - 'a']++;
  }

  for(int i = 0;i<26;i++){
    ans *= ((c[i] + 1) % mod);
  }
  printf("%lld",ans - 1);
}


#include<stdio.h>

int main(void){
  char S[100001];
  int n;
  long long int ans = 1,mod = 1000000007,c[26] = {0};

  scanf("%d",&n);
  scanf("%s",S);

  for(int i = 0;i<n;i++){
    c[S[i] - 'a']++;
  }

  for(int i = 0;i<26;i++){
    ans *= (c[i] + 1) % mod;
  }
  printf("%lld",ans - 1);
}


inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
MOD = Math.pow(10, 9) + 7
N = inp.shift() * 1
S = inp.shift()
o = {}
for (i=0; i<N; i++) {
    o[S[i]] = (o[S[i]] || 0) + 1
}
ans = 1
for (var k in o) {
    ans *= o[k] + 1
    ans = ans % MOD
}
console.log(ans - 1)


var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = myconv(next(),1);
  var s = next();
  var count = {};
  var output = 1;
  var mod = 1000000007;
  for(var i = 0; i < N; i++){
    if(count[s[i]] == null){
       count[s[i]] = 1;
    }else{
       count[s[i]]++;
    }
  }
  var keys = Object.keys(count);
  for(var i = 0; i < keys.length; i++){
    output = (output * (count[keys[i]] + 1)) % mod;
  }
  myout(output - 1);
}


"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt(), S = cin.getStr();
    let C = {};
    for (let n = 0; n < S.length; n++) {
        let c = C[S[n]] || 0;
        C[S[n]] = ++c;
    }
    const MOD = 1e9 + 7;
    let ans = 1;
    for (let n in C) {
        ans = (ans * (C[n] + 1)) % MOD;
    }
    ans = (ans - 1 + MOD) % MOD;
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));


var lines = [];
var MOD = Math.pow(10, 9) + 7
var result = 1;

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0]);
    var S = lines[1].split("");

    S.sort((a, b) => a.charCodeAt(0) - b.charCodeAt(0));

    var counter = []; var cnt = 1;
    for (var i = 1; i < N; i++) {
        if (S[i - 1] !== S[i]) { counter.push(cnt); cnt = 0; }
        cnt++;
    }

    counter.push(cnt);

    for (var i = 0; i < counter.length; i++) {
        result *= counter[i] + 1;
    }

    console.log(result - 1);
});


var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var MOD = Math.pow(10, 9) + 7;

    var N = lines[0];
    var S = lines[1].split("");

    var alphabet = {};

    // 余事象で解く
    var result = 1;

    // baa   = 2C1 * 3C1 - 1 =  5
    // baaa  = 2C1 * 4C1 - 1 = 7
    // bcaaa = 2C1 * 2C1 * 4C1 -1 = 15
    // aabbc = 3C1 * 3C1 * 2C1 -1 = 17

    for (var i = 0; i < N; i++) { alphabet[S[i]] === undefined ? alphabet[S[i]] = 1 : alphabet[S[i]]++ }
    Object.keys(alphabet).forEach(function (key) {
        result *= nCm(alphabet[key] + 1, 1);
    });
    console.log(result - 1);

});
function nPm(n, m) {
    var result = 1; var counter = 0;

    while (counter < m) {
        result *= n
        n -= 1; counter++;
    }
    return (result);
}

function nCm(n, m) {
    return (nPm(n, m) / nPm(m, m));
}


var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var MOD = Math.pow(10,9)+7;

    var N = lines[0];
    var S = lines[1].split("");
    var result = 1;
    var alphabet = {};

    for (var i = 0; i < N; i++) {
        if ((alphabet[S[i]]) === undefined) {
            alphabet[S[i]] = 0;
        }
        alphabet[S[i]]++;
    }

    for (var i = 0; i < Object.keys(alphabet).length; i++) {
        result = result * (alphabet[S[i]] + 1);
        result = result % MOD;
    }
    console.log((result - 1) % MOD);
});


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	s := getNextString(scanner)
	mod := int64(1e9 + 7)
	cc := make([]int64, 26)

	for i := 0; i < n; i++ {
		cc[s[i]-'a']++
	}

	ans := int64(1)
	for i := 0; i < 26; i++ {
		ans *= (cc[i] + 1)
		ans %= mod
	}
	ans--
	ans = ((ans % mod) + mod) % mod
	fmt.Fprintln(writer, ans)
	writer.Flush()
}


package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

const mod = 1e9 + 7

func main() {
	b := [26 + 'a']int{}
	rd := bufio.NewReader(os.Stdin)
	var (
		by  byte
		err error
	)
	for err != io.EOF {
		by, err = rd.ReadByte()
		b[by]++
	}

	r := 1
	for i := 'a'; i < 26+'a'; i++ {
		r = r * (b[i] + 1) % mod
	}
	fmt.Println(r - 1)
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var N int

func main() {
	N = nextInt()
	S := nextString()
	div := int(math.Pow10(9) + 7)
	alpha := make([]int, 26)
	for i := 0; i < 26; i++ {
		alpha[i] = 1
	}
	for i := 0; i < N; i++ {
		alpha[int(S[i])-97] += 1
	}
	result := 1
	for i := 0; i < 26; i++ {
		result = result * alpha[i]
		result = result % div
	}
	fmt.Printf("%v", result-1)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func MaxIn2Values(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinIn2Values(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func MinIn4Values(a int, b int, c int, d int) int {
	e := MinIn2Values(a, b)
	f := MinIn2Values(c, d)
	return MinIn2Values(e, f)
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func PrimeFactorsMap(n int) map[int]int {
	pfs := map[int]int{}
	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2]++
		} else {
			pfs[2] = 1
		}
		//pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i]++
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		if _, ok := pfs[n]; ok {
			pfs[n]++
		} else {
			pfs[n] = 1
		}
	}

	return pfs
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

func swap(a int, b int) (int, int) {
	return b, a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {

	return a / b * gcd(a, b)

}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

func main() {
	sc.Split(bufio.ScanWords)
	var S string
	N := nextInt()
	fmt.Scan(&S)
	al := make([]int, 26)

	for i := 0; i < N; i++ {
		al[S[i]-'a']++
	}

	ans := 1
	for i := 0; i < N; i++ {
		ans = ans * (al[i] + 1)
		ans %= mod
	}

	fmt.Println(ans - 1)
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func PrimeFactorsMap(n int) map[int]int {
	pfs := map[int]int{}
	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2]++
		} else {
			pfs[2] = 1
		}
		//pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i]++
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		if _, ok := pfs[n]; ok {
			pfs[n]++
		} else {
			pfs[n] = 1
		}
	}

	return pfs
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

func swap(a int, b int) (int, int) {
	return b, a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {

	return a / b * gcd(a, b)

}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	S := nextStr()
	al := make([]int, 26)

	for i := 0; i < N; i++ {
		al[S[i]-'a']++
	}

	ans := 1
	for i := 0; i < N; i++ {
		ans = ans * (al[i] + 1)
		ans %= mod
	}

	fmt.Println(ans - 1)
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func PrimeFactorsMap(n int) map[int]int {
	pfs := map[int]int{}
	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2]++
		} else {
			pfs[2] = 1
		}
		//pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i]++
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		if _, ok := pfs[n]; ok {
			pfs[n]++
		} else {
			pfs[n] = 1
		}
	}

	return pfs
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

func swap(a int, b int) (int, int) {
	return b, a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {

	return a / b * gcd(a, b)

}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	S := nextStr()
	al := make([]int64, 26)

	for i := 0; i < N; i++ {
		al[S[i]-'a']++
	}

	ans := int64(1)
	for i := 0; i < N; i++ {
		ans = (ans * (al[i] + 1)) % mod
	}
	fmt.Println(ans - 1)
}


n=gets.to_i
s=gets.chomp
l=[]
26.times do |i|
  l[i]=s.count((i+"a".ord).chr)+1
end
puts (l.inject(:*)-1)%(10**9+7)


N=gets.to_i
S=gets.chomp
mod = 10**9+7
b = 1
(?a..?z).each do |c|
    cnt = S.count(c)
    b *= cnt+1
end

puts (b-1) % mod


n = gets.to_i
s = gets.chomp
mod = 10 ** 9 + 7

puts ("a".."z").to_a.inject(1){|r,i| r * (s.count(i) + 1) % mod} - 1


n=gets.to_i
s=gets.chomp
l=[1]*26
s.each_char do |c|
  l[c.ord-"a".ord]+=1
end
puts l.inject(:*)-1


n = gets.chomp.to_i
s = gets.chomp
h  = Hash.new(0)

n.times do |i|
  h[s[i]] += 1
end

MOD = 10**9 + 7
ans = 1
h.each do |k,v|
  ans *= (v + 1) % MOD
end

puts ans - 1


n = gets.to_i
h = Hash.new(0)
gets.chomp.each_char { |c| h[c] += 1 }
ret = 0
mod = 10**9 + 7

1.upto(h.size) do |i|
  h.keys.combination(i) do |arr|
    ret += arr.map { |e| h[e] }.inject { |i, j| i * j % mod }
  end
end

puts ret % mod


macro_rules! read_line {
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim_right().to_owned()
    }};
}

fn main() {
    let m = 1_000_000_007u64;
    read_line!();
    let s = read_line!();
    let mut ab = vec![0u64; 26];
    for c in s.bytes() {
        ab[(c - 'a' as u8) as usize] += 1;
    }
    let mut ans = 1u64;
    for c in 0..26 {
        ans = (ans * (ab[c] + 1)) % m;
    }
    ans = (ans + m - 1) % m;
    println!("{}", ans);
}


#![allow(unused_imports)]

#[macro_use]
mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    macro_rules! input {
        ($($name:ident : $t:tt),*,) => {
            input!($($name: $t),*)
        };
        ($($name:ident : $t:tt),*) => {
            let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
            $(
                let $name = unsafe { _read_value!(_scanned, $t) };
            )*
        };
    }

    macro_rules! _read_value {
        ($scanned:expr, ($($t:tt),*)) => {
            ($(_read_value!($scanned, $t)),*)
        };
        ($scanned:expr, [$t:tt; $n:expr]) => {
            (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
        };
        ($scanned:expr, _bytes) => {
            _read_value!($scanned, String).into_bytes()
        };
        ($scanned:expr, _1based) => {
            _read_value!($scanned, usize) - 1
        };
        ($scanned:expr, $t:ty) => {
            $scanned.next::<$t>()
        };
    }

    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf_ = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf_).unwrap();
            debug_assert!(str::from_utf8(&buf_).is_ok());
            debug_assert!(buf_.iter().all(|&c| u32::from(c) <= 0x7F));
            Scanned { buf: buf_, pos: 0 }
        }

        #[inline]
        pub unsafe fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            str::from_utf8_unchecked(target).parse().unwrap()
        }
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Stderr, StderrLock, Stdout, StdoutLock, Write};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, mem, thread, u16, u32, u64, u8};

const M: u64 = 1_000_000_007;

fn main() {
    input! {
        _n: usize,
        s: _bytes,
    }
    let mut kinds = [0; 27];
    for c in s {
        kinds[(c - b'a') as usize] += 1;
    }
    let ret = kinds.iter().map(|&n| n + 1).fold(1, |a, b| (a * b) % M) - 1;
    println!("{}", ret);
}


use std::io::*;
use std::ops::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let _n = i.read::<usize>();
    let s = i.read_line().as_bytes();
    writeln!(o, "{}", solve(s)).unwrap();
}
fn solve(s: &[u8]) -> usize {
    let mut cs = vec![0; 26];
    for s in s {
        cs[(s - b'a') as usize] += 1;
    }
    let mut r = Mod::new(1);
    for c in &cs {
        r *= *c + 1;
    }
    (r - 1).0
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

    #[derive(Clone, Copy)]
    pub struct Mod(pub usize);

    use std::fmt;
    impl fmt::Debug for Mod {
        fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
            write!(f, "{:?}", self.0)
        }
    }

    const MOD_BASE: usize = 1000000007;
    const MOD_INV_POW: usize = 1000000005;

    impl Mod {
        pub fn new(n: usize) -> Self {
            Mod(n % MOD_BASE)
        }
        pub fn pow(self, mut exp: usize) -> Self {
            let mut b = self;
            let mut r = Mod(1);
            while exp != 0 {
                if exp % 2 == 1 {
                    r *= b;
                }
                exp /= 2;
                b = b * b;
            }
            r
        }
        pub fn inverse_element(self) -> Self {
            self.pow(MOD_INV_POW)
        }
    }

    macro_rules! mod_op {
        (($ot:ident, $f:ident), ($ot_a:ident, $f_a:ident), $($rhs:ty : $e:expr,)*) => {
            $(
            impl $ot<$rhs> for Mod {
                type Output = Self;
                fn $f(self, rhs: $rhs) -> Self {
                    ($e)(self, rhs)
                }
            }
            impl $ot_a<$rhs> for Mod {
                fn $f_a(&mut self, rhs: $rhs) {
                    *self = ($e)(*self, rhs)
                }
            }
            )*
        }
    }

    mod_op!(
        (Add, add),
        (AddAssign, add_assign),
        Mod : |l: Mod, r: Mod| Mod::new(l.0 + r.0),
        usize : |l: Mod, r: usize| l + Mod::new(r),
    );

    mod_op!(
        (Mul, mul),
        (MulAssign, mul_assign),
        Mod : |l: Mod, r: Mod| Mod::new(l.0 * r.0),
        usize : |l: Mod, r: usize| l * Mod::new(r),
    );

    mod_op!(
        (Sub, sub),
        (SubAssign, sub_assign),
        Mod : |l: Mod, r: Mod| Mod::new(MOD_BASE + l.0 - r.0),
        usize : |l: Mod, r: usize| l - Mod::new(r),
    );

    mod_op!(
        (Div, div),
        (DivAssign, div_assign),
        Mod : |l: Mod, r: Mod| l * r.inverse_element(),
        usize : |l: Mod, r: usize| l / Mod::new(r),
    );

}


use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let m = 1000_000_000 + 7;
    let n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();
    let mut map = HashMap::new();
    let mut ret = 1;
    for c in s.iter() {
        let count = map.entry(c).or_insert(0);
        *count += 1;
    }
    for (_, value) in map {
        ret *= value + 1;
        ret %= m;
    }
    println!("{}", (ret + m - 1) % m);
}


use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let m = 1000_000_000 + 7;
    let n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();
    let mut map = HashMap::new();
    let mut ret = 1;
    for c in s.iter() {
        let count = map.entry(c).or_insert(0);
        *count += 1;
    }
    for (_, value) in map {
        ret *= value + 1;
        ret %= m;
    }
    println!("{}", ret - 1);
}


#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        _n: usize,
        s: Chars,
    }
    let res = 1_000_000_007;
    let mut ans = 1;
    let mut count = vec![0; 26];
    for &c in &s {
        count[c as usize - 'a' as usize] += 1;
    }
    for i in 0..26 {
        if count[i] != 0 {
            ans *= (count[i] + 1) % res as u64;
        }
    }
    ans -= 1;
    println!("{}", ans);
}


let N = Int(readLine()!)!
let S = readLine()!.characters
var cnt = [Character: Int]()
for c in S {
    cnt[c] = (cnt[c] ?? 0) + 1
}
print(cnt.values.reduce(1){$0*($1+1)%1000000007}-1)


let N = Int(readLine()!)!
let S = readLine()!.characters
var cnt = [Character: Int]()
for c in S {
    cnt[c] = (cnt[c] ?? 0) + 1
}
print(cnt.values.reduce(1){$0*($1+1)%1000000007})


let N = Int(readLine()!)!
let S = readLine()!
var cnt = [Character: Int]()
for c in S.characters {
    cnt[c] = (cnt[c] ?? 0) + 1
}
print(cnt.values.reduce(1){$0*($1+1%1000000007)})


const base: number = Math.pow(10, 9) + 7;
export class Main {
  static main(input): string {
    const [n, s]: string[] = input.split("\n");
    const count: {[key: string]: number} = {};
    for (let i: number = 0, len = Number(n); i < len; i++) {
      const char: string = s.charAt(i);
      if (count[char] === undefined) {
        count[char] = 0;
      }
      count[char] += 1;
    }
    let result = 1;
    Object.keys(count).forEach(key => {
      result = (result * (count[key] + 1)) % base;
    })
    return `${result > 0 ? (result - 1) : (base - 1)}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
}

let reader = new Reader();
let N = reader.readInt();
let S = reader.readLine();
let counter: Map<string, number> = new Map();
let alphabet = "abcdefghijklmnopqrstuvwxyz";

for(let c of alphabet) {
	counter.set(c, 0);
}

let answer = 0,
	modulo = 1000000007;
for(let c of S) {
	let sum = 1;
	counter.forEach((value, key) => {
		if (key != c)
			sum = (sum*(value+1))%modulo;
	});
	answer = (answer+sum)%modulo;
	counter.set(c, counter.get(c)+1);
}

console.log(answer);


import { readFileSync } from 'fs'

const mod = 10 ** 9 + 7

function main(input: string) {
  const [, S] = input.split('\n')

  // 各文字の数を集計
  const counts = Array.from(S).reduce(
    (acc, v) => ({ ...acc, [v]: (acc[v] || 0) + 1 }),
    {} as Record<string, number>
  )

  // 組み合わせを計算
  const pattern = Object.keys(counts).reduce((acc, key) => {
    const result = acc * (counts[key] + 1)
    return result % mod
  }, 1)

  // 0文字選択のパターンを排除
  const result = (pattern - 1 + mod) % mod

  console.log(result)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


import fs = require('fs');
if(process.argv[1].match(/Main.js$/)) { console.log(main(fs.readFileSync('/dev/stdin', 'utf8').split(/[\r\n\t ]/))); }

export function main(strings: string[]): string {
	const ret: any[] = [];
	const str = strings[1];

	const answers = xxx('', str);
	ret.push(answers.length % (10**9+7))

	return ret.join('\n') + '\n';
}

function xxx(s1: string, s2: string, ret: string[] = []): string[] {
	if(s2.length === 1) {
		if(s1.length) {
			if(s1.includes(s2[0]) === false) {
				Array.prototype.push.apply(ret, [s1 + s2]);
			}
			Array.prototype.push.apply(ret, [s1     ]);
			return ret;
		} else {
			Array.prototype.push.apply(ret, [s2]     );
			return ret
		}
	}
	if(s1.includes(s2[0]) === false) {
		Array.prototype.push.apply(xxx(s1 + s2[0], s2.substr(1), ret));
	}
	Array.prototype.push.apply(xxx(s1        , s2.substr(1), ret));
	return ret;
}


import fs = require('fs');
if(process.argv[1].match(/Main.js$/)) { console.log(main(fs.readFileSync('/dev/stdin', 'utf8').split(/[\r\n\t ]/))); }

export function main(strings: string[]): string {
	const ret: any[] = [];
	const str = strings[1];

	let n = 0;
	for(let i=1, i2=2 ** str.length; i<i2; i++) {
		let s = i.toString(2);
		s = '0'.repeat(str.length - s.length) + s;

		let sub = '';
		let ok = true;
		for(let j=0; j<s.length && ok; j++) {
			if(s[j] === '1') {
				if(sub.indexOf(str[j]) !== -1) {
					ok = false;
				} else {
					sub += str[j];
				}
			}
		}

		if(ok) {
			n++;
		}
	}
	ret.push(n % (10**9+7))

	return ret.join('\n') + '\n';
}


import fs = require('fs');
if(process.argv[1].match(/Main.js$/)) { console.log(main(fs.readFileSync('/dev/stdin', 'utf8').split(/[\r\n\t ]/))); }

export function main(strings: string[]): string {
	const ret: any[] = [];
	const str = strings[1];

	let n = 0;
	for(let i=1, i2=2 ** str.length; i<i2; i++) {
		let s = i.toString(2);
		s = '0'.repeat(str.length - s.length) + s;

		let sub = '';
		let ok = true;
		for(let j=0; j<s.length; j++) {
			if(s[j] === '1') {
				if(sub.indexOf(str[j]) !== -1) {
					ok = false;
				} else {
					sub += str[j];
				}
			}
		}

		if(ok) {
			n++;
		}
	}
	ret.push(n % (10**9+7))

	return ret.join('\n') + '\n';
}


a,b,c,d = (int(i) for i in input().split())
if (abs(a-b)<=d and abs(b-c)<=d) or abs(a-c)<=d: print("Yes")
else: print("No")


def main():
    a,b,c,d = map(int, input().split())
    if abs(a-c)<=d:
        return "Yes"
    elif abs(a-b)<=d and abs(b-c)<=d:
        return "Yes"
    else:
        return "No"

if __name__ == '__main__':
    print(main())


a,b,c,d=map(int,input().split())
print('Yes' if abs(a-b)<=d and abs(b-c)<=d or abs(c-a)<=d else 'No')


a,b,c,d=map(int,input().split())

if abs(a-c)<=d or abs(a-b)+abs(b-c)<=2*d:
    ans="Yes"
else:
    ans="No"
print(ans)


a,b,c,d = map(int,input().split())

if (a-b) <= d and (b-c) <= d:
    print('Yes')
elif (a-c) <= d:
    print('Yes')
else:
    print('No')


a,b,c,d = map(int,input().split())

if (b-a) <= d and (c-b) <= d:
    print('Yes')
    exit()
elif (c-a) <= d:
    print('Yes')
    exit()

print('No')


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int a, b, c, d;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        d = sc.nextInt();
        solve();
    }

    void solve() {
        if (Math.abs(a - c) <= d || (Math.abs(a - b) <= d && Math.abs(b - c) <= d)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    private static Scanner sc;
    private static int[][] neg8 = new int[][]{{-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}};
    private static int[][] neg4 = new int[][]{{1, 0}, {0, -1}, {-1, 0}, {0, 1}};

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int d = sc.nextInt();
            boolean ab = Math.abs(a - b) <= d;
            boolean bc = Math.abs(b - c) <= d;
            boolean ac = Math.abs(a - c) <= d;
            System.out.println((ac || (ab && bc)) ? "Yes" : "No");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }

    private static double distance(int x1, int x2, int y1, int y2) {
        return Math.sqrt((Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2)));
    }

    private static boolean nextPermutation(int[] nums) {
        int i = nums.length - 2;
        while (i >= 0 && nums[i + 1] <= nums[i]) {
            i--;
        }
        boolean swap = false;
        if (i >= 0) {
            int j = nums.length - 1;
            while (j >= 0 && nums[j] <= nums[i]) {
                j--;
            }
            swap(nums, i, j);
            swap = true;
        }
        reverse(nums, i + 1);
        return swap;
    }

    private static void reverse(int[] nums, int start) {
        int i = start, j = nums.length - 1;
        while (i < j) {
            swap(nums, i, j);
            i++;
            j--;
        }
    }

    private static void swap(int[] nums, int i, int j) {
        int temp = nums[i];
        nums[i] = nums[j];
        nums[j] = temp;
    }
}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
    // template start ---8<-----------8<---
	FastScanner sc = new FastScanner(System.in);
	static PrintWriter out;

	public static void main(String[] args) throws IOException {
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	// template end ---8<-----------8<---

	void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if (Math.abs(a-b)<=d && Math.abs(c-b)<=d || Math.abs(a-c)<=d) {
			out.println("Yes");
		} else {
			out.println("No");
		}

	}

    // template start ---8<-----------8<---
	class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		FastScanner(InputStream in) {
			this.in = in;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	class Random {
		private long seed;
		private final long multiplier = 0x5DEECE66DL, addend = 0xBL, mask = (1L << 48) - 1;
		int bits, val;

		Random(long seed) {
			this.seed = seed;
		}

		int nextInt(int n) {
			do {
				bits = (int) ((seed = (seed * multiplier + addend) & mask) >>> 17);
				val = bits % n;
			} while (bits - val + (n - 1) < 0);
			return val;
		}

		double nextDouble() {
			return nextInt(10000000) / 10000000.0;
		}
	}

	final double TEMP = 10;
	static final long TL = 5850;
	static boolean submit = true;
    // template end ---8<-----------8<---

}


import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      int D = sc.nextInt();

      if((Math.abs(A-B)<=D|| Math.abs(B-C)<=D) && (Math.abs(A-C)<=D)){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}


import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      int D = sc.nextInt();

      if((Math.abs(A-B)<=D)|| (Math.abs(B-C)<=D) && (Math.abs(A-C)<=D)){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}


import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      int D = sc.nextInt();
      int[] E = new int[]{A,B,C};
      Arrays.sort(E);

      if(E[2]-E[1]<=D||E[1]-E[0]<=D||E[2]-E[0]<=D){
        System.out.println("Yes");
      }else if(E[2]-E[1]>D&&E[1]-E[0]>D&&E[2]-E[0]>D){
        System.out.println("No");
      }
    }
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
int a, b, c, d;

scanf("%d", &a);
scanf("%d", &b);
scanf("%d", &c);
scanf("%d", &d);

if((abs(b - a) <= d)&&(abs(c - b) <= d) || (abs(a - c) <= d))
    printf("Yes\n");
else
    printf("No\n");
}


#include <cstdio>
#include <cmath>
using namespace std;

int main() {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    bool ok = abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d);
    printf("%s\n", ok ? "Yes" : "No");
}


#include <stdio.h>

int abs(int a) {
  return a < 0 ? -a : a;
}

int main() {
  int a,b,c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);

  if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d;
cin>>a>>b>>c>>d;
if(abs(a-b)<=d||abs(a-c)<=d||abs(b-c)<=d)
    cout<<"Yes";
else cout<<"No";
       return 0;
}


#include <iostream>

using namespace std ;
#define ref(i,n) for(int i =0;i<n;i++)
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ab,ac,bc;
    ab = abs(a-b);
    ac = abs(a-c);
    bc = abs(b-c);
    if(ab > d && ac >d)
    	cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}


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

int main() {

  int a, b, c, d;
  cin >> a >> b >> c >>d;

  if(c-a<=d || (b-a<=d && c-b<=d)) cout << "Yes" << endl;
  else cout << "No" << endl;

}


#include <stdio.h>
#include <stdlib.h>
int main(void){
  int a,b,c,d;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&d);

if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)){
 printf("Yes");
} else {
 printf("No");
}

return 0;
}


#include <stdio.h>
#include <math.h>

int main(void)
{
  int a, b, c, d;
  int ab, bc, ac;

  scanf("%d %d %d %d", &a, &b, &c, &d);
  ac = abs(c - a);
  ab = abs(b - a);
  bc = abs(c - b);
  if(ac <= d || (ab <= d && bc <=d)) printf("Yes\n");
  else printf("No\n");

  return 0;
}


#include <stdio.h>
#include <math.h>

int main(void){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(abs(a-c)<=d)printf("Yes\n");
    else if(abs(a-b)<=d && abs(b-c)<=d)printf("Yes\n");
    else printf("No\n");
    return 0;
}


#include <stdio.h>

int main() {
  int i,j,k,a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  while((1>a)&&(a>100)&&(1>b)&&(b>100)&&(1>c)&&(c>100)&&(1>d)&&(d>100)){
    scanf("%d %d %d %d",&a,&b,&c,&d);
  }
  i=a-b;
  if(i<0)i=i*(-1);
  j=b-c;
  if(j<0)j=j*(-1);
  k=c-a;
  if(k<0)k=k*(-1);
  if(((i<=d)&&(j<=d))||((i<=d)&&(k<=d))||((j<=d)&&(k<=d))){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main() {
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if (abs(a - b) <= d || abs(a - c) <= d || abs(b - c) <= d) {
		printf("Yes\n");
	} else {
	printf("No\n");
	}
}


#include <stdio.h>

int main() {
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if (a - b <= d) {
		if (b - c <=d)
		{
			printf("Yes\n");
		} else
		{
			printf("No\n");
		}
	} else
	{
		printf("No\n");
	}
}


function main(input) {
	const args = input.split(' ');
	const a = parseInt(args[0], 10);
	const b = parseInt(args[1], 10);
	const c = parseInt(args[2], 10);
	const d = parseInt(args[3], 10);
	var t = 0;
	if(Math.abs(a-c)<=d){
		t = 1;
	} else if(Math.abs(a-b)<=d && Math.abs(b-c)<=d){
		t = 1;
	}
	if(t == 1){
		console.log('Yes');
	} else {
		console.log('No');
	}
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main (input) {
  const a = parseInt(input.split(' ')[0],10);
  const b = parseInt(input.split(' ')[1],10);
  const c = parseInt(input.split(' ')[2],10);
  const d = parseInt(input.split(' ')[3],10);

  if (d >= Math.abs(a-c)) {
    console.log('Yes');
  } else {
    if (d >= Math.abs(b-c)) {
      if (d >= Math.abs(a-b)) {
        console.log('Yes');
      } else {
        console.log('No');
      }
    } else {
      console.log('No');
    }
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
	var c = parseInt(tmp[2], 10);
	var d = parseInt(tmp[3], 10);
	//出力
	if( (Math.abs(a-c)<=d) || ( (Math.abs(a-b) <= d)&&(Math.abs(b-c)<=d) ) )
	  console.log('Yes');
	else
	  console.log('No');
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function main(input) {
    var a = input[1].split(" ").map(v=>v-0);
    var ans = false;
    if(Math.abs(a[0]-a[1]) <= a[3] && Math.abs(a[1]-a[2]) <= a[3]) ans = true;
    if(Math.abs(a[0]-a[2]) <= a[3] ) ans = true;
    console.log(ans?"Yes":"No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,1);
  var set = new Set();
  set.add(1);
  for(var i = 2; i <= Math.sqrt(input); i++){
    var tmp = i;
    while(tmp <= input){
       set.add(tmp);
      tmp *= i;
    }
  }
  while(true){
     if(set.has(input)){
        myout(input);
       return;
     }else{
       input--;
     }
  }

}
Main(myin());


function Main(input){
	input1 = input.trim().split(' ').map(v=>parseInt(v,10));
    a = input1[0];
    b = input1[1];
    c = input1[2];
    d = input1[3];

    if((Math.abs(a-c) <=d) || (Math.abs(a-b) <=d) && Math.abs(b-c) <=d)){
    console.log('Yes');
    }else{
    console.log('No');
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));


package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	if abs(a-b) <= d && abs(b-c) <= d || abs(a-c) <= d {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func abs(x int) int {
	if x <0 {
		x = -x
	}
	return x
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d float64
	fmt.Scan(&a, &b, &c, &d)
	if math.Abs(a - c) <= d {
		fmt.Println("Yes")
		return
	} else if math.Abs(a - b) <= d && math.Abs(b - c) <= d {
		fmt.Println("Yes")
		return
	} else {
		fmt.Println("No")
		return
	}
}


package main

import (
    . "fmt"
    "math"
)

func main() {
    var a, b, c, d float64
    Scanf("%f %f %f %f", &a, &b, &c, &d)

    if math.Abs(c - a) <= d || math.Abs(b - a) <= d && math.Abs(c - b) <= d {
        Println("Yes")
    } else {
        Println("No")
    }
 }


package main

import (
	"fmt"
)

func abs(a int) int {
	if a < 0 {
		return (-1) * a
	}
	return a
}

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	if abs(a-b) <= d && abs(b-c) <= d {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


package main

import (
	"fmt"
)

func abs(a int) int {
	if a < 0 {
		return (-1) * a
	}
	return a
}

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	if abs(a-b) >= 0 && abs(b-c) >= 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	if b - a >= d && c - b >= d {
	fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

a,b,c,d=get_i
if (a-c).abs<=d
    puts "Yes"
elsif (a-b).abs<=d and (b-c).abs<=d
    puts "Yes"
else
    puts "No"
end


a, b, c, d = gets.chomp.split.map(&:to_i)

if (a - b).abs <= d && (b - c).abs <= d
  puts "Yes"
elsif (a - c).abs <= d
  puts "Yes"
else
  puts "No"
end


a,b,c,d = gets.to_s.split.map{|t|t.to_i}

if (a-c).abs <= d || ((a-b).abs <= d && (b-c).abs <= d )
  puts "Yes"
else
  puts "No"
end


*a,d=gets.split.map(&:to_i)
a,b,c=a.sort
puts (a-c).abs>d&&((b-c).abs>d||(a-b).abs>d) ?"No":"Yes"


*a,d=gets.split.map(&:to_i)
a,b,c=a.sort
puts (a-b).abs>d&&(b-c).abs>d ?"No":"Yes"


a,b,c,d=gets.split.map(&:to_i)
puts (a-b).abs>d&&(b-c).abs>d ?"No":"Yes"


use std::io::*;
use std::str::FromStr;

/*
The read function reads a string according to each one.
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn abs(x:i64)->i64{
    if x<0{
	-1*x
    }else {
	x
    }
}

//main function
fn main() {
    let a:i64 = read();
    let b:i64 = read();
    let c:i64 = read();
    let d:i64 = read();
    if (abs(a-c) <= d) || (abs(a-b) <= d && abs(b-c) <= d) {
	println!("Yes");
    }else{
	println!("No");
    }
}


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i32,
        b: i32,
        c: i32,
        d: i32,
    }
    if (a - c).abs() <= d ||
       ((a - b).abs() <= d && (b - c).abs() <= d) {
        println!("Yes");
    } else {
        println!("No");
    }
}


use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	let c = v[2];
	let d = v[3];
	if (c - a).abs() <= d || ((b - a).abs() <= d && (c - b).abs() <= d) {
		println!("Yes");
	}else{
		println!("No");
	}
}


use std::io::*;
use std::str::FromStr;

pub fn read<t: FromStr>() -> t {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    let d: i64 = read();

    if (a - c).abs() > d && (a - b).abs() > d && (b - c).abs() > d {
        println!("No");
    } else {
        println!("Yes")
    }
}


use std::io;
use std::io::*;

fn read_input() -> String {
  let mut buffer = String::new();
  let stdin = io::stdin();
  let mut handle = stdin.lock();
  let _ = handle.read_to_string(&mut buffer);
  buffer.clone()
}

fn main() {
    let buffer = read_input();
    let mut iter = buffer.split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();
    let d: i32 = iter.next().unwrap().parse().unwrap();
    if (a - b).abs() <= d {
      println!("Yes");
    } else if (c - a).abs() <= d && (c - b).abs() <= d {
      println!("Yes");
    } else {
      println!("No");
    }
}


use std::io;
use std::io::*;

fn read_input() -> String {
  let mut buffer = String::new();
  let stdin = io::stdin();
  let mut handle = stdin.lock();
  let _ = handle.read_to_string(&mut buffer);
  buffer.clone()
}

fn main() {
    let buffer = read_input();
    let mut iter = buffer.split(' ');
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();
    let d: i32 = iter.next().unwrap().parse().unwrap();
    if (a - b).abs() <= d {
      println!("Yes");
    } else if (c - a).abs() <= d && (c - b).abs() <= d {
      println!("Yes");
    } else {
      println!("No");
    }
}


let i=readLine()!.characters.split(" ").map{Int(String($0))!};print(abs(i[0]-i[2])>i[3]&&(abs(i[0]-i[1])>i[3]||abs(i[1]-i[2])>i[3]) ?"No":"Yes")


let i=readLine()!.characters.split(" ").map{Int(String($0))!};print(abs(i[0]-i[2])>i[3]||(abs(i[0]-i[1])>i[3]&&abs(i[1]-i[2])>i[3]) ?"No":"Yes")


let i=readLine()!.characters.split(" ").map{Int(String($0))!};print((abs(i[0]-i[2])>i[3])||abs(i[0]-i[1])>i[3]&&abs(i[1]-i[2])>i[3] ?"No":"Yes")


let i=readLine()!.characters.split(" ").map{Int(String())!};print((abs(i[0]-i[2])>i[3])||abs(i[0]-i[1])>i[3]&&abs(i[1]-i[2])>i[3] ?"No":"Yes")


const main = (input) => {
  input = input.split(' ');
  const a = parseInt(input[0], 10);
  const b = parseInt(input[1], 10);
  const c = parseInt(input[2], 10);
  const d = parseInt(input[3], 10);

  const resultA = Math.abs(a-b);
  const resultB = Math.abs(a-c);
  const resultC = Math.abs(b-c);

  if (resultB<=d|| resultA<=d&&resultC<=d) {
    console.log("Yes");
  }else{
    console.log("No");
  }

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [a, b, c, d] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

let is = false
if (Math.abs(a - b) <= d && Math.abs(b - c) <= d) is = true
if (Math.abs(a - c) <= d) is = true

console.log(is ? 'Yes' : 'No')


import * as fs from 'fs'
const inputs = fs.readFileSync('/dev/stdin', 'utf8').split(/\r?\n/)
const [a, b, c, d] = inputs.shift()!.split(' ').map(s => parseInt(s, 10))

const can = (x: number, y: number) => Math.abs(x - y) <= d;
console.log((can(a, c) || (can(a, b) && can(b, c))) ? 'Yes' : 'No')


const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let [a,b,c,d]=nrin(4)
  out(abs(a-c<=d)+0||(abs(a-b<=d)+0&&abs(b-c<=d)+0)?'Yes':'No')
}
main()


const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let [a,b,c,d]=nrin(4)
  out(abs(a-c<=d)||(abs(a-b<=d)&&abs(b-c<=d))?'Yes':'No')
}
main()


const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let [a,m]=[desc(nrin(3)),nin()]
  out(a[0]-a[1]<=m&&a[1]-a[2]<=m?'Yes':'No')
}
main()


n,k00 = list(map(int, input().split()))

ks = [k00]
ns = [0]
k0 = k00+0
n0 = 0
while k0 >1:
    k0 = ((k0*-1)//2)*-1
    n0 += 1
    ks.append(k0)
    ns.append(n0)

for i,j in enumerate(ks):
    if n == j:
        ks1 = [1]
        for k,l in enumerate(ks[i:][:-1]):
            ks1.append(ks[i:][k] - ks[i:][k+1])
        ns1 = ns[i:]
        break
    elif n > j:
        ks1 = [n-j+1]
        for k,l in enumerate(ks[i:][:-1]):
            ks1.append(ks[i:][k] - ks[i:][k+1])
        ns1 = ns[i:]
        break

ans = 0
b1 = 1/n
for i,j in enumerate(ks1):
        ans += (ks1[i])*((1/2)**ns1[i])*(1/n)

print(ans)


from math import ceil
n,k=map(int,input().split())
b=k
p=0
pp=1
nn=n
while b>0:
    c = max(nn-b+1,0)
    z = c/(n*pp)
    p += z
    pp *= 2
    nn = min(b-1, nn)
    if b == 1:
        b = 0
    else:
        b = ceil(b/2)
print(p)


import math
n,k=map(int,input().split())
now=k
cnt=0 #割った回数
ans=max(0,n-k+1)
while now>=1:
    a=now/2
    b=math.ceil(a) #最小値
    if now!=int(now):
        c=int(now) #最大値
    else:
        c=int(now)-1
    cnt+=1
    if b>min(k-1,n): #調べる最大値(K-1かNの小さいほう)が最小値より大きいとき
        now=a
        continue
    elif c>min(k-1,n): #最大値より小さいとき
        c=min(k-1,n) #最大値を補正
    ans+=1/(2**cnt)*(c-b+1)
    now=a
    if now==1:
        break
print(ans/n)


n,k=map(int,input().split())

ans = 0

for i in range(1,n-1):
  p = i
  r = 1
  while < k:
    p*=2
    r/=2
  ans+=r

ans/=n

print(ans)


def main():
    n, k = map(int, input().split())
    ans = 0.0
    for t in range(1, n + 1):
        cnt = 0
        now = t
        per = 1.0
        while now < k - 1:
            per /= 2
            now *= 2
        ans += per / n
    print('{:.20}'.format(ans))
    pass

if __name__ == '__main__':
    main()


def main():
    n, k = map(int, input().split())
    ans = 0.0
    for t in range(1, n + 1):
        cnt = 0
        now = t
        per = 1.0
        while now < k - 1:
            per /= 2
            now *= 2
        ans += per / n
    print(ans)
    pass

if __name__ == '__main__':
    main()


import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        int[] nk = in.readLineAsIntArray();
        final int N = nk[0];
        final int K = nk[1];

        double p = 0.0;

        double mul = 1.0;

        int high = N;
        int k = K;
        while (high > 0) {
            if (high >= k) {
                p += (Math.max(high - k + 1, 0) * mul) / N;
                high = k - 1;
            } else {
            }
            if(k%2==0){
                k = k / 2;
            }else{
                k = k / 2 + 1;
            }
            mul *= 0.5;
        }
        System.out.println(p);

    }

    static class CustomReader extends BufferedReader {

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in));
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }

    }
}


import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();
        int N, K;
        {int[] a = r.ii(); N = a[0]; K = a[1];}
        double ans = 0;
        if(K <= N)
            ans += N-K+1;
        for(int i = 1; i <= Math.min(K-1, N); i++){
            int n = 0;
            int score = i;
            while(score < K){
                n++;
                score *= 2;
            }
            ans += Math.pow(0.5, n);
        }
        ans /= N;
        print(ans);
    }
    static void print(Object o){
        System.out.println(o.toString());
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int Int(String s){
            return Integer.parseInt(s);
        }
        int i() throws IOException{
        return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
    }
}


import java.io.*;
import java.util.*;
import java.math.*;
// import java.awt.Point;

public class Main {
    InputStream is;
    PrintWriter out;
    String INPUT = "";

    // static int mod = 1_000_000_007;
    int mod = 998244353;
    // long inf = Long.MAX_VALUE/2;
    int inf = Integer.MAX_VALUE/2;

    void solve(){
        int n = ni();
        int k = ni();
        double ans = 0;
        for(int i = 1; i <= n; i++){
            long r = i;
            double tmp = 1.0/n;
            while(r<k){
                tmp /= 2;
                r *= 2;
            }
            ans += tmp;
        }
        out.println(ans);
    }

    void run() throws Exception
    {
        is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        out = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
        solve();
        out.flush();
        if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
    }

    public static void main(String[] args) throws Exception { new Main().run(); }

    private byte[] inbuf = new byte[1024];
    private int lenbuf = 0, ptrbuf = 0;

    private int readByte()
    {
        if(lenbuf == -1)throw new InputMismatchException();
        if(ptrbuf >= lenbuf){
            ptrbuf = 0;
            try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
            if(lenbuf <= 0)return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
    private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

    private double nd() { return Double.parseDouble(ns()); }
    private char nc() { return (char)skip(); }

    private String ns()
    {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while(!(isSpaceChar(b) && b != ' ')){
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n)
    {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while(p < n && !(isSpaceChar(b))){
            buf[p++] = (char)b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m)
    {
        char[][] map = new char[n][];
        for(int i = 0;i < n;i++)map[i] = ns(m);
        return map;
    }

    private int[] na(int n)
    {
        int[] a = new int[n];
        for(int i = 0;i < n;i++)a[i] = ni();
        return a;
    }

    private int ni()
    {
        int num = 0, b;
        boolean minus = false;
        while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if(b == '-'){
            minus = true;
            b = readByte();
        }

        while(true){
            if(b >= '0' && b <= '9'){
                num = num * 10 + (b - '0');
            }else{
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl()
    {
        long num = 0;
        int b;
        boolean minus = false;
        while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if(b == '-'){
            minus = true;
            b = readByte();
        }

        while(true){
            if(b >= '0' && b <= '9'){
                num = num * 10 + (b - '0');
            }else{
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }

}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        double ans = 0.0;
        double tmp1 = 1.0 / n;
        for (int i = 1; i <= n; i++) {
            int tmp2 = i;
            int j = 0;
            for (; ; j++) {
                if(tmp2 > k) {
                    break;
                }
                tmp2 *= 2;
            }

            ans += Math.pow(0.5, j) * tmp1;
        }
        System.out.println(ans);
    }
}


import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main2 {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();

		double all = 0;
		for( int i = 1 ; i <= n ; i++ ) {
			int now = i;
			int p_all = 1;
			while( now < k ) {
				now *= 2;
				p_all *= 2;
			}
			all += 1.0/n/p_all;
		}

		System.out.println( (double)all );

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int t = 0;
		long bottom = 1, up = 1;
		BigDecimal p = BigDecimal.ZERO;
		for(long i = 1; i <= n; i++) {
			if(i >= k) {
				up += bottom;
			}else if(i == 1){
				bottom = min(i);
			}else {
				long x = min(i);
				up += bottom / x;
			}
		}
		BigDecimal b = BigDecimal.valueOf(n*bottom);
		BigDecimal u = BigDecimal.valueOf(up);
		System.out.println(u.divide(b, 12, BigDecimal.ROUND_HALF_UP));
	}

	static long min(long i) {
		long x = 0;
		double r = 0;
		r = (Math.log(10) - Math.log(i)) / Math.log(2);
		x = (long)r;
		if(r-x != 0) {
			x++;
		}
		long big = (long)Math.pow(2, x);
		return big;
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


#include <bits/stdc++.h>

using namespace std;

int main() {

    int n,k;
    cin >> n >> k;

    double ans = 0;
    for (int i = 1; i <= n; ++i) {
        long long cur = i;
        int cnt = 0;
        while(cur < k) cnt++, cur += cur;
        double m = 1;
        while(cnt--) m *= 0.5;
        ans += (m * (1. / n));
    }

    printf("%.10lf\n", ans);
    return 0;
}


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

int main() {
  cout <<fixed <<setprecision(15);
  double n,k; cin >>n >>k;
  double ans;
  for (int i=1; i<=min(n,k-1); i++){
    int buf = i;
    double p = 1;
    while(buf<k){ buf *= 2; p /= 2;}
    ans += p;
  }
  for (int i=k; i<=n; i++){
    ans++;
  }
  ans /= n;
  cout <<ans;
  cout <<endl;
}


#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

int main()
{
	int32_t N, K;
	cin >> N >> K;

	double res = 0;
	for (int32_t i = 1; i <= N; i++) {
		double prob = 1.0;
		int32_t value = i;
		while (value < K) {
			value *= 2;
			prob /= 2.0;
		}
		res += prob;
	}
	res /= N;

	cout << fixed << std::setprecision(std::numeric_limits<double>::max_digits10) << res << endl;

	return 0;
}


#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
using namespace std;
using ll = long long;

int main()
{
    int N, K;
    cin >> N >> K;

    double ans = 0.0;

    rep(i, 0, N)
    {
        int n = i + 1;

        int s = n;
        int t = n;
        int sk = K - 1;
        int c = 1;

        while (s < sk)
        {
            t *= 2;
            s += t;
            c++;
        }
        ans += static_cast<double>(1 / static_cast<double>(N)) * static_cast<double>(pow(0.5, c));
    }

    cout << ans;

    return 0;
}


#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int n,k;
  	double ans = 0.0;
	cin >> n >> k;
  	if(n>=k) {
    	ans += (double)(n-k+1)/n;
    }
	rep(i, min(n, k-1)){
      	int kk = max((log((double)k/(i+1))/log(2)), 0.0)+1;
      	ans += pow(0.5, kk)/ n;
	}
	printf("%.9lf\n", ans);
}


#include<bits/stdc++.h>
using namespace std;int main(){int a,b;scanf("%d%d",&a,&b);double ans=0;for(int i=1;i<=a;i++){double pos=1.0/a;int now=i;while(now<b){now*=2;pos/=2;}ans+=pos;}printf("%.12llf\n",ans);return 0;}


#include <stdio.h>
int main(void){
    int n,k,cnt,i,j;
    double ans=0;
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++){
        j=i;
        double p=1;
        while(j<k){
            j*=2;
            p*=0.5;
        }
        ans += p/n;
    }
    printf("%.10f\n",ans);
}


#include <stdio.h>
int main(void){
    int n,k,cnt,i,j;
    double ans=0;
    scanf("%d%d",&n,&k);
    for(i=1;i<n+1;i++){
        j=i;
        cnt=0;
        while(j<k){
            j*=2;
            cnt++;
        }
        ans += (double)1/(1<<cnt);
    }
    printf("%.10f",ans/n);
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

#define POWER_MAX 20

int main(void) {
    int num, llimit;
    get_int2(&num, &llimit);

    static int power2[POWER_MAX];
    power2[0] = 1;
    int i = 0;
    for(i = 1; i < POWER_MAX; i++) {
        power2[i] = power2[i-1] * 2;
    }

    static int map[POWER_MAX];
    for(i = 1; i <= num; i++) {
        int point = i;
        int cnt = 0;
        while(point < llimit) {
            cnt++;
            point *= 2;
        }
        map[cnt]++;
#ifdef DEBUG
        printf("%d -> %d\n", i, cnt);
#endif
    }

    double ans = 0;
    for(i = 0; i < POWER_MAX; i++) {
        ans += 1.0 / num * (1.0/power2[i]) * map[i];
    }
    printf("%.10lf\n", ans);
    return 0;
}


#include <stdio.h>
#define _CRT_SECURE_NO_WARNINGS

int main() {
	double N = 0;	//input:サイコロの面数
	double K = 0;	//input:勝利に必要な点数
	int count = 0;
	double victory_probability = 0;
	int i = 0;

	do {
		scanf("%lf %lf", &N, &K);
	} while ((N < 1 && 100000 < N) && (K < 1 && 100000 < K));

	while (N <= K) {
		K = K / 2;
		count++;
	}
	for (i = 1; i <= N; i++) {
		victory_probability += (1 / N) * ((1 / 2) ^ count);
		count--;
	}
	return 0;
}


#include <stdio.h>
#define _CRT_SECURE_NO_WARNINGS

int main() {
	int N = 0;	//input:サイコロの面数
	int K = 0;	//input:勝利に必要な点数
	int count = 0;
	double victory_probability = 0;
	int i = 0;

	do {
		scanf("%d %d", &N, &K);
	} while ((N < 1 && 100000 < N) && (K < 1 && 100000 < K));

	while (N <= K) {
		K = K / 2;
		count++;
	}
	for (i = 1; i <= N; i++) {
		victory_probability += (1 / N) * ((1 / 2) ^ count);
		count--;
	}
	return 0;
}


#include <stdio.h>
#define _CRT_SECURE_NO_WARNINGS

int main() {
	int N = 0;	//input:サイコロの面数
	int K = 0;	//input:勝利に必要な点数
	int count = 0;
	double victory_probability = 0;
	int i = 0;

	do {
		scanf("%d %d", &N, &K);
	} while ((1 <= N && N <= 100000) && (1 <= K && K <= 100000));

	while (N <= K) {
		K = K / 2;
		count++;
	}
	for (i = 1; i <= N; i++) {
		victory_probability += (1 / N) * ((1 / 2) ^ count);
		count--;
	}
	return 0;
}


function main(input){
  input = input.split(' ').map(Number);
  const N = input[0];
  const K = input[1];

  var result = 0;

  for(i = 1;i <= N;i++){
    var tmp = 1/N;
  	var now = i;
  	while(now < K){
      now *= 2;
      tmp /= 2;
    }
    result += tmp;
  }

  console.log(result.toString().slice(0,14));
}
main(require('fs').readFileSync('/dev/stdin','utf8'));


var input=require('fs').readFileSync('/dev/stdin', 'utf8');
  var inputs=input.split(' ');
  var n=Number(inputs[0]),k=Number(inputs[1]);
  var rate=0;
  for(var i=1; i<=n; i++){
    var rate2=1,n2=i;
    while(n2<k){
      rate2/=2;
      n2*=2;
    }
    rate+=rate2;
  }
  console.log(rate/n);


"use strict";
function Main(input) {
  const args = input.split(' ').map(m => parseInt(m));
  const N = args.shift();
  const K = args.shift()
  let aN = N;
  let rK = K;
  let counter = 1;
  let rate = 0;
  while (true) {
    if (aN >= rK) {
      const win = aN - rK + 1;
      rate += (win / (counter * N));
      aN = rK - 1;
    }
    if (rK === 1) {
      break;
    }
    rK = Math.ceil(rK / 2);
    counter = counter * 2;
  }

  console.log(rate);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const calc = (n, k) =>{
    let cnt = 0
    while(n>k){
        n *= 2
        cnt++
    }
    return cnt
}
const Main = () => {
    const [N, K] = nextIntArray()
    let ans = 0
    for(let i = 1; i<=N; i++){
        const cnt = calc(i, K)
        ans += 1/N*(0.5**cnt)
    }
    console.log(ans)
}
Main()


"use strict";

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const K = parseInt(arg[0].split(" ")[1]);

    let answer = [];

    for(let i=1; i<=N; i++) {
        let now = i;
        let cnt = 1;

        while(true) {
            if(now > K) break;
            now *= 2;
            cnt++;
            // console.log("now:" + now);
            // console.log("cnt:" + cnt);
        }

        // console.log(cnt - 1);

        let temp = (1 / N) * Math.pow(0.5, cnt - 1)

        answer.push(temp);
    }

    console.log(answer.reduce((m,n)=>m+n));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main(input) {
        const line = input.split(' ');
        const n = line[0];
        const k = line[1];

        let result = 0;
        for (let i = 1; i <= n; ++i) {
                let j = i;
                let toss = 0;
                for (let j = i; j < k; j*=2, ++toss) ;

                result += Math.pow(0.5, toss) * (1 / n);
        }
        console.log(`${result}`);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


package main

import "fmt"

var n, k int
var ans float64

func main() {
  fmt.Scanf("%d%d", &n, &k)

  for i := 1; i <= n; i++ {
    p := 1/float64(n)
    if i >= k {
      ans += p
      continue
    }
    now := i
    for now < k {
      p /= 2
      now *= 2
    }
    ans += p
  }
  fmt.Println(ans)
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var n, k int
	fmt.Fscan(read, &n, &k)

	ans := 0.0
	p0 := 1.0 / float64(n)
	p := 0.0
	for i := 1; i <= n; i++ {
		p = p0
		for j := i; j < k; j *= 2 {
			p /= 2.0
		}
		ans += p
	}
	fmt.Fprintln(write, ans)
}


package main

import "fmt"

func main() {
	var (
		N, K int
		ans  float64
	)
	fmt.Scan(&N, &K)

	for i := 1; i <= N; i++ {
		rate := 1 / float64(N)
		point := i
		for point < K {
			point *= 2
			rate /= 2
		}
		ans += rate
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
	"math"
)

func cnt(a, b int) int {
	var cnt int = 0
	if a == 1 {
		a = 2
		cnt += 1
	}
	for b > 0 {
		b = b / a
		cnt++
	}
	return cnt - 1
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	var ans float64
	for i := 1; i <= n; i++ {
		if i >= k {
			ans += 1.0 / float64(n)
			continue
		}

		win := cnt(i, k)
		ans += math.Pow(1.0/2.0, float64(win)) * (1.0 / float64(n))
	}

	fmt.Printf("%.10f\n", ans)
}


package main

import (
	"fmt"
	"math"
)

func b2i(b bool) int {
	if b {
		return 1
	}
	return 0
}

func cnt(a, b int) int {
	var cnt int = 0
	if a == 1 {
		a = 2
		cnt += 1
	}
	for b > 0 {
		b = b / a
		cnt++
	}
	return cnt - 1
}

func main() {
	var n, k int
	fmt.Scan(&n)
	fmt.Scan(&k)

	var ans float64
	for i := 1; i <= n; i++ {
		if i >= k {
			ans += 1.0 / float64(n)
			continue
		}

		win := cnt(i, k)
		ans += math.Pow(0.5, float64(win)) * (1.0 / float64(n))
	}

	fmt.Println(ans)
}