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

const int N = 1e5 + 5;
const double PI = 3.14159265358979323846264338327;
int n, px, py;
int x[N], y[N];

inline double dist(int x1, int y1, int x2, int y2){
	return sqrtl((x1 - x2) * 1LL * (x1 - x2) + (y1 - y2) * 1LL * (y1 - y2));
}

inline double dist_to_segment(int x1, int y1, int x2, int y2){
    int dx = x2 - x1;
    int dy = y2 - y1;
    double t = ((px - x1) * 1.0 * dx + (py - y1) * 1.0 * dy) / (dx * 1.0 * dx + dy * 1.0 * dy);
    // See if this represents one of the segment end points or a point in the middle.
    if (t < 0){
        dx = px - x1;
        dy = py - y1;
    }
    else if (t > 1){
        dx = px - x2;
        dy = py - y2;
    }
    else{
    	double cx = x1 + t * dx, cy = y1 * t + dy;
        dx = px - cx;
        dy = py - cy;
    }
    return sqrt(dx * 1.0 * dx + dy * 1.0 * dy);
}

int main(){
	cin >> n >> px >> py;
	for(int i = 1; i <= n; i++){
		cin >> x[i] >> y[i];
	}
	double radius_large = 0;
	for(int i = 1; i <= n; i++){
		radius_large = max(radius_large, dist(px, py, x[i], y[i]));
	}
	double radius_small = 1e18;
	for(int i = 1; i <= n; i++){
		int j = (i < n) ? (i + 1) : (1);
		radius_small = min(radius_small, dist_to_segment(x[i], y[i], x[j], y[j]));
	}
	double ans = PI * (radius_large * radius_large - radius_small * radius_small);
	cout << fixed << setprecision(18) << ans << '\n';
}


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

const int N = 1e5 + 5;
const double PI = 3.14159265358979323846264338327;
int n, px, py;
int x[N], y[N];

inline double dist(int x1, int y1, int x2, int y2){
	return sqrtl((x1 - x2) * 1LL * (x1 - x2) + (y1 - y2) * 1LL * (y1 - y2));
}

inline double dist_to_segment(int x1, int y1, int x2, int y2){
    int dx = x2 - x1;
    int dy = y2 - y1;
    double t = ((px - x1) * 1.0 * dx + (py - y1) * 1.0 * dy) * 1.0 / (dx * 1.0 * dx + dy * 1.0 * dy);
    // See if this represents one of the segment end points or a point in the middle.
    if (t < 0){
        dx = px - x1;
        dy = py - y1;
    }
    else if (t > 1){
        dx = px - x2;
        dy = py - y2;
    }
    else{
    	double cx = x1 + t * dx, cy = y1 + t * dy;
        dx = px - cx;
        dy = py - cy;
    }
    return sqrt(dx * 1.0 * dx + dy * 1.0 * dy);
}

int main(){
	cin >> n >> px >> py;
	for(int i = 1; i <= n; i++){
		cin >> x[i] >> y[i];
	}
	double r1 = 0;
	for(int i = 1; i <= n; i++){
		r1 = max(r1, dist(px, py, x[i], y[i]));
	}
	double r2 = 1e18;
	for(int i = 1; i <= n; i++){
		int j = (i < n) ? (i + 1) : (1);
		r2 = min(r2, dist_to_segment(x[i], y[i], x[j], y[j]));
	}
	double ans = PI * (r1 * r1 - r2 * r2);
	cout << fixed << setprecision(18) << ans << '\n';
}


#include <iostream>
#include <vector>
#include <cmath>

const double pi = 3.1415926535897932384626433832795;

bool test(long long x1, long long y1, long long x2, long long y2, long long x3, long long y3)
{
    long long vx1 = x2 - x1;
    long long vy1 = y2 - y1;
    long long vx2 = x3 - x1;
    long long vy2 = y3 - y1;
    return ((vx1 * vx2 + vy1 * vy2) > 0);
}

long long vc(long long x1, long long y1, long long x2, long long y2)
{
    return (x1 * y2 - x2 * y1);
}

using namespace std;

int main()
{
    int n, i;
    long long x0, y0, x, y, xp, yp, xf, yf;
    double rmx = 0, rmn = 1000000000;
    cin >> n >> x0 >> y0;
    cin >> xf >> yf;
    xp = xf;
    yp = yf;
    for (i = 0; i < n - 1; i++)
    {
        cin >> x >> y;
        rmx = max(rmx, hypot(x - x0, y - y0));
        rmn = min(rmn, hypot(x - x0, y - y0));
        if (test(xp, yp, x, y, x0, y0) && test(x, y, xp, yp, x0, y0))
            rmn = min(rmn, abs(vc(x - x0, y - y0, xp - x0, yp - y0)) / (hypot(x - xp, y - yp)));
        xp = x;
        yp = y;
    }
    x = xf;
    y = yf;
    rmx = max(rmx, hypot(x - x0, y - y0));
    rmn = min(rmn, hypot(x - x0, y - y0));
    if (test(xp, yp, x, y, x0, y0) && test(x, y, xp, yp, x0, y0))
        rmn = min(rmn, abs(vc(x - x0, y - y0, xp - x0, yp - y0)) / (hypot(x - xp, y - yp)));
    cout.precision(30);
//    cout << rmx << ' ' << rmn << endl;
    cout << pi * (rmx*rmx - rmn*rmn);
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>

const double pi = 3.1415926535897932384626433832795;

using namespace std;

int main()
{
    int n, i;
    long long x0, y0, x, y;
    long long rmx = 0, rmn = 1000000000000000ll;
    cin >> n >> x0 >> y0;
    for (i = 0; i < n; i++)
    {
        cin >> x >> y;
        rmx = max(rmx, (x - x0) * (x - x0) + (y - y0)*(y - y0));
        rmn = min(rmn, (x - x0) * (x - x0) + (y - y0)*(y - y0));
    }
    cout.precision(30);
    cout << pi * (rmx - rmn);
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>

const long double pi = 3.1415926535897932384626433832795;

using namespace std;

int main()
{
    long long n, x0, y0, i, x, y;
    long double rmx = 0, rmn = 100000000000000;
    cin >> n >> x0 >> y0;
    for (i = 0; i < n; i++)
    {
        cin >> x >> y;
        rmx = max(rmx, (x0 - x)*(x0 - x) + (y0 - y)*(y0 - y));
        rmn = min(rmn, (x0 - x)*(x0 - x) + (y0 - y)*(y0 - y));
    }
    cout.precision(30);
    cout << pi * (rmx - rmn);
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>

const double pi = 3.1415926535897932384626433832795;

bool test(long long x1, long long y1, long long x2, long long y2, long long x3, long long y3)
{
    long long vx1 = x2 - x1;
    long long vy1 = y2 - y1;
    long long vx2 = x3 - x1;
    long long vy2 = y3 - y1;
    return ((vx1 * vx2 + vy1 * vy2) > 0);
}

long long vc(long long x1, long long y1, long long x2, long long y2)
{
    return (x1 * y2 - x2 * y1);
}

using namespace std;

int main()
{
    int n, i;
    long long x0, y0, x, y, xp, yp, xf, yf;
    double rmx = 0, rmn = 1000000000;
    cin >> n >> x0 >> y0;
    cin >> xf >> yf;
    xp = xf;
    yp = yf;
    for (i = 0; i < n - 1; i++)
    {
        cin >> x >> y;
        rmx = max(rmx, hypot(x - x0, y - y0));
        rmn = min(rmn, hypot(x - x0, y - y0));
        if (test(xp, yp, x, y, x0, y0) && test(x, y, xp, yp, x0, y0))
            rmn = min(rmn, abs(vc(x - x0, y - y0, xp - x0, yp - y0)) / (hypot(x - xp, y - yp)));
        xp = x;
        yp = y;
    }
    x = xf;
    y = yf;
    rmx = max(rmx, hypot(x - x0, y - y0));
    rmn = min(rmn, hypot(x - x0, y - y0));
    if (test(xp, yp, x, y, x0, y0) && test(x, y, xp, yp, x0, y0))
        rmn = min(rmn, abs(vc(x - x0, y - y0, xp - x0, yp - y0)) / (hypot(x - xp, y - yp)));
    cout.precision(30);
    cout << rmx << ' ' << rmn << endl;
    cout << pi * (rmx*rmx - rmn*rmn);
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>

const double pi = 3.1415926535897932384626433832795;

using namespace std;

int main()
{
    long long n, x0, y0, i, x, y;
    double rmx = 0, rmn = 1000000000;
    cin >> n >> x0 >> y0;
    for (i = 0; i < n; i++)
    {
        cin >> x >> y;
        rmx = max(rmx, (double)(x0 - x)*(x0 - x) + (y0 - y)*(y0 - y));
        rmn = min(rmn, (double)(x0 - x)*(x0 - x) + (y0 - y)*(y0 - y));
    }
    cout.precision(30);
    cout << pi * (rmx - rmn);
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>

const double pi = 3.14159265358979;

using namespace std;

int main()
{
    long long n, x0, y0, i, x, y;
    long long rmx = 0, rmn = 1000000000;
    cin >> n >> x0 >> y0;
    for (i = 0; i < n; i++)
    {
        cin >> x >> y;
        rmx = max(rmx, (x0 - x)*(x0 - x) + (y0 - y)*(y0 - y));
        rmn = min(rmn, (x0 - x)*(x0 - x) + (y0 - y)*(y0 - y));
    }
    cout.precision(20);
    cout << pi * (rmx - rmn);
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>

const double pi = 3.1415926535897932384626433832795;

bool test(long long x1, long long y1, long long x2, long long y2, long long x3, long long y3)
{
    long long vx1 = x2 - x1;
    long long vy1 = y2 - y1;
    long long vx2 = x3 - x1;
    long long vy2 = y3 - y1;
    return ((vx1 * vx2 + vy1 * vy2) > 0);
}

long long vc(long long x1, long long y1, long long x2, long long y2)
{
    return (x1 * y2 - x2 * y1);
}

using namespace std;

int main()
{
    int n, i;
    long long x0, y0, x, y, xp, yp, xf, yf;
    double rmx = 0, rmn = 1000000000;
    cin >> n >> x0 >> y0;
    cin >> xf >> yf;
    xp = xf;
    yp = yf;
    for (i = 0; i < n - 1; i++)
    {
        cin >> x >> y;
        rmx = max(rmx, hypot(x - x0, y - y0));
        rmn = min(rmn, hypot(x - x0, y - y0));
        if (test(xp, yp, x, y, x0, y0) && test(x, y, xp, yp, x0, y0))
            rmn = min(rmn, abs(vc(x - x0, y - y0, xp - x0, yp - y0)) / (hypot(x - xp, y - yp) * 2));
        xp = x;
        yp = y;
    }
    x = xf;
    y = yf;
    rmx = max(rmx, hypot(x - x0, y - y0));
    rmn = min(rmn, hypot(x - x0, y - y0));
    if (test(xp, yp, x, y, x0, y0) && test(x, y, xp, yp, x0, y0))
        rmn = min(rmn, abs(vc(x - x0, y - y0, xp - x0, yp - y0)) / (hypot(x - xp, y - yp) * 2));
    xp = x;
    yp = y;
    cout.precision(30);
    cout << pi * (rmx*rmx - rmn*rmn);
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>

const double pi = 3.1415926535897;

using namespace std;

int main()
{
    int n, i;
    int x0, y0, x, y;
    double rmx = 0, rmn = 1000000000;
    cin >> n >> x0 >> y0;
    for (i = 0; i < n; i++)
    {
        cin >> x >> y;
        rmx = max(rmx, hypot(x - x0, y - y0));
        rmn = min(rmn, hypot(x - x0, y - y0));
    }
    cout.precision(30);
    cout << pi * (rmx*rmx - rmn*rmn);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl

typedef long double llf;
typedef pair<int, int> P;
#define X first
#define Y second

const llf PI = 3.14159265358979323846264338327950288419716939937510, EPS = 1e-9;
const int MAX = 1<<17;

struct prav {
  llf a, b, c;
};

P sred;

llf Sq(llf x)
{
  return x * x;
}

llf Dist(P a, P b)
{
  return sqrt(Sq(a.X - b.X) + Sq(a.Y - b.Y));
}

llf DistPrav(prav p, P toc)
{
  return abs(p.a * toc.X + p.b * toc.Y + p.c) / sqrt((Sq(p.a) + Sq(p.b)));
}

prav Pravac(P a, P b)
{
  return prav { (llf) b.Y - a.Y, (llf) a.X - b.X, (llf) b.X * a.Y - a.X * b.Y };
}

P tocke[MAX];

int main()
{
  int n;

  scanf("%d%d%d", &n, &sred.X, &sred.Y);

  for (int i=0; i<n; i++)
    scanf("%d%d", &tocke[i].X, &tocke[i].Y);

  llf minn = 1e15, maxx = -1e15;
  for (int i=0; i<n; i++) {
    llf dd = Dist(sred, tocke[i]);
    minn = min(minn, dd);
    maxx = max(maxx, dd);

    int slj = (i + 1) % n;
    if (Sq(Dist(tocke[i], tocke[slj])) + Sq(Dist(tocke[i], sred)) + EPS > Sq(Dist(tocke[slj], sred)) &&
        Sq(Dist(tocke[i], tocke[slj])) + Sq(Dist(tocke[slj], sred)) + EPS > Sq(Dist(tocke[i], sred))) {

      minn = min(minn, DistPrav(Pravac(tocke[i], tocke[slj]), sred));
    }
  }

  printf("%.15lf\n", (double) ((Sq(maxx) - Sq(minn)) * PI));

  return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl

typedef long double llf;
typedef pair<int, int> P;
#define X first
#define Y second

const llf PI = 3.14159265358979323846264338327950288419716939937510, EPS = 1e-9;
const int MAX = 1<<17;

struct prav {
  llf a, b, c;
};

P sred;

llf Sq(llf x)
{
  return x * x;
}

llf Dist(P a, P b)
{
  return sqrt(Sq(a.X - b.X) + Sq(a.Y - b.Y));
}

llf DistPrav(prav p, P toc)
{
  return abs(p.a * toc.X + p.b * toc.Y + p.c) / sqrt((Sq(p.a) + Sq(p.b)));
}

prav Pravac(P a, P b)
{
  return prav { (llf) b.Y - a.Y, (llf) a.X - b.X, (llf) b.X * a.Y - (llf) a.X * b.Y };
}

P tocke[MAX];

int main()
{
  int n;

  scanf("%d%d%d", &n, &sred.X, &sred.Y);

  for (int i=0; i<n; i++)
    scanf("%d%d", &tocke[i].X, &tocke[i].Y);

  llf minn = 1e15, maxx = -1e15;
  for (int i=0; i<n; i++) {
    llf dd = Dist(sred, tocke[i]);
    minn = min(minn, dd);
    maxx = max(maxx, dd);

    int slj = (i + 1) % n;
    if (Sq(Dist(tocke[i], tocke[slj])) + Sq(Dist(tocke[i], sred)) + EPS > Sq(Dist(tocke[slj], sred)) &&
        Sq(Dist(tocke[i], tocke[slj])) + Sq(Dist(tocke[slj], sred)) + EPS > Sq(Dist(tocke[i], sred))) {

      minn = min(minn, DistPrav(Pravac(tocke[i], tocke[slj]), sred));
    }
  }

  printf("%.15lf\n", (double) ((Sq(maxx) - Sq(minn)) * PI));

  return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

double minn = 1e9, maxx = -1e9;

P sred;

double Dist(P a, P b)
{
  return sqrt((a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y));
}

int main()
{
  int n;

  scanf("%d%d%d", &n, &sred.X, &sred.Y);

  for (int i=0; i<n; i++) {
    P tmp;
    scanf("%d%d", &tmp.X, &tmp.Y);
    double dd = Dist(sred, tmp);
    minn = min(minn, dd);
    maxx = max(maxx, dd);
  }

  printf("%.10lf\n", (maxx * maxx - minn * minn) * M_PI);

  return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

long double minn = 1e18, maxx = -1e18;
const long double PI = 3.14159265358979323846264338327950288419716939937510;

P sred;

long double Dist(P a, P b)
{
  return sqrt((a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y));
}

int main()
{
  int n;

  scanf("%d%d%d", &n, &sred.X, &sred.Y);

  for (int i=0; i<n; i++) {
    P tmp;
    scanf("%d%d", &tmp.X, &tmp.Y);
    long double dd = Dist(sred, tmp);
    minn = min(minn, dd);
    maxx = max(maxx, dd);
  }

  printf("%.15lf\n", (double) ((maxx * maxx - minn * minn) * PI));

  return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl

typedef long double llf;
typedef pair<int, int> P;
#define X first
#define Y second

const llf PI = 3.14159265358979323846264338327950288419716939937510;
const int MAX = 1<<20;

struct prav {
  llf a, b, c;
};

P sred;

llf Sq(llf x)
{
  return x * x;
}

llf Dist(P a, P b)
{
  return sqrt(Sq(a.X - b.X) + Sq(a.Y - b.Y));
}

llf DistPrav(prav p, P toc)
{
  return abs(p.a * toc.X + p.b * toc.Y + p.c) / sqrt((Sq(p.a) + Sq(p.b)));
}

prav Pravac(P a, P b)
{
  return prav { (llf) b.Y - a.Y, (llf) a.X - b.X, (llf) b.X * a.Y - a.X * b.Y };
}

P tocke[MAX];

int main()
{
  int n;

  scanf("%d%d%d", &n, &sred.X, &sred.Y);

  for (int i=0; i<n; i++)
    scanf("%d%d", &tocke[i].X, &tocke[i].Y);

  llf minn = 1e15, maxx = -1e15;
  for (int i=0; i<n; i++) {
    llf dd = Dist(sred, tocke[i]);
    minn = min(minn, dd);
    maxx = max(maxx, dd);

    int slj = (i + 1) % n;
    if (Sq(Dist(tocke[i], tocke[slj])) + Sq(Dist(tocke[i], sred)) > Sq(Dist(tocke[slj], sred)) &&
        Sq(Dist(tocke[i], tocke[slj])) + Sq(Dist(tocke[slj], sred)) > Sq(Dist(tocke[i], sred))) {

      minn = min(minn, DistPrav(Pravac(tocke[i], tocke[slj]), sred));
    }
  }

  printf("%.15lf\n", (double) ((maxx * maxx - minn * minn) * PI));

  return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

double minn = 1e9, maxx = -1e9;
const double PI = 3.14159265358979323846264338327950288419716939937510;

P sred;

double Dist(P a, P b)
{
  return sqrt((a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y));
}

int main()
{
  int n;

  scanf("%d%d%d", &n, &sred.X, &sred.Y);

  for (int i=0; i<n; i++) {
    P tmp;
    scanf("%d%d", &tmp.X, &tmp.Y);
    double dd = Dist(sred, tmp);
    minn = min(minn, dd);
    maxx = max(maxx, dd);
  }

  printf("%.10lf\n", (maxx * maxx - minn * minn) * PI);

  return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef long double llf;
typedef pair<int, int> P;
#define X first
#define Y second

const llf PI = 3.14159265358979323846264338327950288419716939937510;
const int MAX = 1<<20;

struct prav {
  llf a, b, c;
};

P sred;

llf Sq(llf x)
{
  return x * x;
}

llf Dist(P a, P b)
{
  return sqrt(Sq(a.X - b.X) + Sq(a.Y - b.Y));
}

llf DistPrav(prav p, P toc)
{
  return abs(p.a * toc.X + p.b * toc.Y + p.c) / (Sq(p.a) + Sq(p.b));
}

prav Pravac(P a, P b)
{
  return prav { (llf) b.Y - a.Y, (llf) a.X - b.X, (llf) b.X * a.Y - a.X * b.Y };
}

P tocke[MAX];

int main()
{
  int n;

  scanf("%d%d%d", &n, &sred.X, &sred.Y);

  for (int i=0; i<n; i++)
    scanf("%d%d", &tocke[i].X, &tocke[i].Y);

  llf minn = 1e15, maxx = -1e15;
  for (int i=0; i<n; i++) {
    llf dd = Dist(sred, tocke[i]);
    minn = min(minn, dd);
    maxx = max(maxx, dd);

    int slj = (i + 1) % n;
    if (Sq(Dist(tocke[i], tocke[slj])) + Sq(Dist(tocke[i], sred)) > Sq(Dist(tocke[slj], sred)) &&
        Sq(Dist(tocke[i], tocke[slj])) + Sq(Dist(tocke[slj], sred)) > Sq(Dist(tocke[i], sred)))
      minn = min(minn, DistPrav(Pravac(tocke[i], tocke[slj]), sred));
  }

  printf("%.15lf\n", (double) ((maxx * maxx - minn * minn) * PI));

  return 0;
}


#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
inline double dist(double a,double b,double c,double d){
	return sqrt((a-c)*(a-c)+(b-d)*(b-d));
}
inline double j(double k1,double k2,double b1,double b2){
	return (b2-b1)/(k1-k2);
}
double dist2(int a,int b,int c1,int d1,int c,int d){
	if(c==c1){
		if(b<=d1&&b>=d){
			return abs(c-a);
		}else{
			return min(dist(a,b,c,d),dist(a,b,c1,d1));
		}
	}
	if(d==d1){
		if(a<=c1&&a>=c){
			return abs(d-b);
		}else{
			return min(dist(a,b,c,d),dist(a,b,c1,d1));
		}
	}
	double k1=((double)d-d1)/((double)c-c1);
	double k2=-1/k1;
	double b1=(double)d-(c*k1);
	double b2=(double)b-(a*k2);
	double x=j(k1,b1,k2,b2);
	if(x>c1&&x>c){
		return min(dist(a,b,c,d),dist(a,b,c1,d1));
	}
	if(x<c1&&x<c){
		return min(dist(a,b,c,d),dist(a,b,c1,d1));
	}
	return dist(a,b,x,k1*x+b1);
}
int main(){
	int n,a,b,c1,d1,c2,d2;double min1,max1;
	cin>>n>>a>>b;
	int c,d;
	cin>>c>>d;
	c2=c;d2=d;
	min1=max1=(dist(a,b,c,d));
	for(int i=2;i<=n;i++){
		c1=c;d1=d;
		cin>>c>>d;
		double dis=dist2(a,b,c1,d1,c,d);
		if(min1>dis)min1=dis;
		dis=dist(a,b,c,d);
		if(max1<dis)max1=dis;
	}
	double dis=dist2(a,b,c2,d2,c,d);
	if(min1>dis)min1=dis;
	dis=dist(a,b,c,d);
	if(max1<dis)max1=dis;
	//cout<<min1<<" "<<max1<<endl;
	cout<<setprecision(15)<<3.141592653589793*(max1*max1-min1*min1);
}


#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
inline double dist(double a,double b,double c,double d){
	return sqrt((a-c)*(a-c)+(b-d)*(b-d));
}
inline double j(double k1,double k2,double b1,double b2){
	return (b2-b1)/(k1-k2);
}
double dist2(int a,int b,int c1,int d1,int c,int d){
	if(c==c1){
		if(b<=d1&&b>=d){
			return abs(c-a);
		}else if(b<=d&&b>=d1){
			return abs(c-a);
		}else{
			return min(dist(a,b,c,d),dist(a,b,c1,d1));
		}
	}
	if(d==d1){
		if(a<=c1&&a>=c){
			return abs(d-b);
		}else if(a<=c&&a>=c1){
			return abs(d-b);
		}else{
			return min(dist(a,b,c,d),dist(a,b,c1,d1));
		}
	}
	double k1=((double)d-d1)/((double)c-c1);
	double k2=-1/k1;
	double b1=(double)d-(c*k1);
	double b2=(double)b-(a*k2);
	double x=j(k1,b1,k2,b2);
	if(x>c1&&x>c){
		return min(dist(a,b,c,d),dist(a,b,c1,d1));
	}
	if(x<c1&&x<c){
		return min(dist(a,b,c,d),dist(a,b,c1,d1));
	}
	return dist(a,b,x,k1*x+b1);
}
int main(){
	int n,a,b,c1,d1,c2,d2;double min1,max1;
	cin>>n>>a>>b;
	int c,d;
	cin>>c>>d;
	c2=c;d2=d;
	min1=max1=(dist(a,b,c,d));
	for(int i=2;i<=n;i++){
		c1=c;d1=d;
		cin>>c>>d;
		double dis=dist2(a,b,c1,d1,c,d);
		cout<<i<<":"<<dis<<endl;
		if(min1>dis)min1=dis;
		dis=dist(a,b,c,d);
		if(max1<dis)max1=dis;
	}
	double dis=dist2(a,b,c2,d2,c,d);
	cout<<n+1<<":"<<dis<<endl;
	if(min1>dis)min1=dis;
	dis=dist(a,b,c,d);
	if(max1<dis)max1=dis;
	cout<<min1<<" "<<max1<<endl;
	cout<<setprecision(15)<<3.141592653589793*(max1*max1-min1*min1);
}


#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
inline double dist(double a,double b,double c,double d){
	return (a-c)*(a-c)+(b-d)*(b-d);
}
inline double j(double k1,double b1,double k2,double b2){
	return (double)(b2-b1)/(k1-k2);
}
double dist2(int a,int b,int c1,int d1,int c,int d){
	//cout<<"dist2("<<a<<","<<b<<","<<c1<<","<<d1<<","<<c<<","<<d<<endl;
	if(c==c1){
		if(b<=d1&&b>=d){
			return (c-a)*(c-a);
		}else if(b<=d&&b>=d1){
			return (c-a)*(c-a);
		}else{
			return min(dist(a,b,c,d),dist(a,b,c1,d1));
		}
	}
	if(d==d1){
		if(a<=c1&&a>=c){
			return (d-b)*(d-b);
		}else if(a<=c&&a>=c1){
			return (d-b)*(d-b);
		}else{
			return min(dist(a,b,c,d),dist(a,b,c1,d1));
		}
	}
	double k1=((double)d-d1)/((double)c-c1);
	double k2=-1/k1;
	double b1=(double)d-(c*k1);
	double b2=(double)b-(a*k2);
	double x=j(k1,b1,k2,b2);
	cout<<x<<endl;
	if(x>c1&&x>c){
		return min(dist(a,b,c,d),dist(a,b,c1,d1));
	}
	if(x<c1&&x<c){
		return min(dist(a,b,c,d),dist(a,b,c1,d1));
	}
	return dist(a,b,x,k1*x+b1);
}
int main(){
	int n,a,b,c1,d1,c2,d2;double min1,max1;
	cin>>n>>a>>b;
	int c,d;
	cin>>c>>d;
	c2=c;d2=d;
	min1=max1=(dist(a,b,c,d));
	//cout<<1<<":"<<min1<<endl;
	for(int i=2;i<=n;i++){
		c1=c;d1=d;
		cin>>c>>d;
		double dis=dist2(a,b,c1,d1,c,d);
		//cout<<i<<":"<<dis<<endl;
		if(min1>dis)min1=dis;
		dis=dist(a,b,c,d);
		if(max1<dis)max1=dis;
	}
	double dis=dist2(a,b,c2,d2,c,d);
	//cout<<n+1<<":"<<dis<<endl;
	if(min1>dis)min1=dis;
	dis=dist(a,b,c,d);
	if(max1<dis)max1=dis;
	//cout<<min1<<" "<<max1<<endl;
	cout<<setprecision(15)<<3.141592653589793*(max1-min1);
}


#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
inline double dist(double a,double b,double c,double d){
	return (a-c)*(a-c)+(b-d)*(b-d);
}
inline double j(double k1,double b1,double k2,double b2){
	return (double)(b2-b1)/(k1-k2);
}
double dist2(int a,int b,int c1,int d1,int c,int d){
	//cout<<"dist2("<<a<<","<<b<<","<<c1<<","<<d1<<","<<c<<","<<d<<endl;
	if(c==c1){
		if(b<=d1&&b>=d){
			return (c-a)*(c-a);
		}else if(b<=d&&b>=d1){
			return (c-a)*(c-a);
		}else{
			return min(dist(a,b,c,d),dist(a,b,c1,d1));
		}
	}
	if(d==d1){
		if(a<=c1&&a>=c){
			return (d-b)*(d-b);
		}else if(a<=c&&a>=c1){
			return (d-b)*(d-b);
		}else{
			return min(dist(a,b,c,d),dist(a,b,c1,d1));
		}
	}
	double k1=((double)d-d1)/((double)c-c1);
	double k2=-1/k1;
	double b1=(double)d-(c*k1);
	double b2=(double)b-(a*k2);
	double x=j(k1,b1,k2,b2);
	cout<<x<<endl;
	if(x>c1&&x>c){
		return min(dist(a,b,c,d),dist(a,b,c1,d1));
	}
	if(x<c1&&x<c){
		return min(dist(a,b,c,d),dist(a,b,c1,d1));
	}
	return dist(a,b,x,k1*x+b1);
}
int main(){
	int n,a,b,c1,d1,c2,d2;double min1,max1;
	cin>>n>>a>>b;
	int c,d;
	cin>>c>>d;
	c2=c;d2=d;
	min1=max1=(dist(a,b,c,d));
	cout<<1<<":"<<min1<<endl;
	for(int i=2;i<=n;i++){
		c1=c;d1=d;
		cin>>c>>d;
		double dis=dist2(a,b,c1,d1,c,d);
		//cout<<i<<":"<<dis<<endl;
		if(min1>dis)min1=dis;
		dis=dist(a,b,c,d);
		if(max1<dis)max1=dis;
	}
	double dis=dist2(a,b,c2,d2,c,d);
	//cout<<n+1<<":"<<dis<<endl;
	if(min1>dis)min1=dis;
	dis=dist(a,b,c,d);
	if(max1<dis)max1=dis;
	//cout<<min1<<" "<<max1<<endl;
	cout<<setprecision(15)<<3.141592653589793*(max1-min1);
}


#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
inline double dist(double a,double b,double c,double d){
	return (a-c)*(a-c)+(b-d)*(b-d);
}
inline double j(double k1,double b1,double k2,double b2){
	return (double)(b2-b1)/(k1-k2);
}
double dist2(int a,int b,int c1,int d1,int c,int d){
	//cout<<"dist2("<<a<<","<<b<<","<<c1<<","<<d1<<","<<c<<","<<d<<endl;
	if(c==c1){
		if(b<=d1&&b>=d){
			return (c-a)*(c-a);
		}else if(b<=d&&b>=d1){
			return (c-a)*(c-a);
		}else{
			return min(dist(a,b,c,d),dist(a,b,c1,d1));
		}
	}
	if(d==d1){
		if(a<=c1&&a>=c){
			return (d-b)*(d-b);
		}else if(a<=c&&a>=c1){
			return (d-b)*(d-b);
		}else{
			return min(dist(a,b,c,d),dist(a,b,c1,d1));
		}
	}
	double k1=((double)d-d1)/((double)c-c1);
	double k2=-1/k1;
	double b1=(double)d-(c*k1);
	double b2=(double)b-(a*k2);
	double x=j(k1,b1,k2,b2);
	//cout<<x<<endl;
	if(x>c1&&x>c){
		return min(dist(a,b,c,d),dist(a,b,c1,d1));
	}
	if(x<c1&&x<c){
		return min(dist(a,b,c,d),dist(a,b,c1,d1));
	}
	return dist(a,b,x,k1*x+b1);
}
int main(){
	int n,a,b,c1,d1,c2,d2;double min1,max1;
	cin>>n>>a>>b;
	int c,d;
	cin>>c>>d;
	c2=c;d2=d;
	min1=max1=(dist(a,b,c,d));
	//cout<<1<<":"<<min1<<endl;
	for(int i=2;i<=n;i++){
		c1=c;d1=d;
		cin>>c>>d;
		double dis=dist2(a,b,c1,d1,c,d);
		//cout<<i<<":"<<dis<<endl;
		if(min1>dis)min1=dis;
		dis=dist(a,b,c,d);
		if(max1<dis)max1=dis;
	}
	double dis=dist2(a,b,c2,d2,c,d);
	//cout<<n+1<<":"<<dis<<endl;
	if(min1>dis)min1=dis;
	dis=dist(a,b,c,d);
	if(max1<dis)max1=dis;
	//cout<<min1<<" "<<max1<<endl;
	cout<<setprecision(15)<<3.141592653589793*(max1-min1);
}


#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
inline double dist(double a,double b,double c,double d){
	return (a-c)*(a-c)+(b-d)*(b-d);
}
inline double j(double k1,double b1,double k2,double b2){
	return (double)(b2-b1)/(k1-k2);
}
double dist2(double a,double b,double c1,double d1,double c,double d){
	if(c==c1){
		if(b<=d1&&b>=d){
			return (c-a)*(c-a);
		}else if(b<=d&&b>=d1){
			return (c-a)*(c-a);
		}else{
			return min(dist(a,b,c,d),dist(a,b,c1,d1));
		}
	}
	if(d==d1){
		if(a<=c1&&a>=c){
			return (d-b)*(d-b);
		}else if(a<=c&&a>=c1){
			return (d-b)*(d-b);
		}else{
			return min(dist(a,b,c,d),dist(a,b,c1,d1));
		}
	}
	double k1=((double)d-d1)/((double)c-c1);
	double k2=-1/k1;
	double b1=(double)d-(c*k1);
	double b2=(double)b-(a*k2);
	double x=j(k1,b1,k2,b2);
	if(x>c1&&x>c){
		return min(dist(a,b,c,d),dist(a,b,c1,d1));
	}
	if(x<c1&&x<c){
		return min(dist(a,b,c,d),dist(a,b,c1,d1));
	}
	return dist(a,b,x,k1*x+b1);
}
int main(){
	int n;double a,b,c,d,c1,d1,c2,d2,min1,max1;
	cin>>n>>a>>b;
	cin>>c>>d;
	c2=c;d2=d;
	min1=max1=(dist(a,b,c,d));
	//cout<<1<<":"<<min1<<endl;
	for(int i=2;i<=n;i++){
		c1=c;d1=d;
		cin>>c>>d;
		double dis=dist2(a,b,c1,d1,c,d);
		//cout<<i<<":"<<dis<<endl;
		if(min1>dis)min1=dis;
		dis=dist(a,b,c,d);
		if(max1<dis)max1=dis;
	}
	double dis=dist2(a,b,c2,d2,c,d);
	//cout<<n+1<<":"<<dis<<endl;
	if(min1>dis)min1=dis;
	dis=dist(a,b,c,d);
	if(max1<dis)max1=dis;
	//cout<<min1<<" "<<max1<<endl;
	cout<<setprecision(12)<<3.141592653589793*(max1-min1);
}


#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
inline double dist(double a,double b,double c,double d){
	return (a-c)*(a-c)+(b-d)*(b-d);
}
inline double j(double k1,double b1,double k2,double b2){
	return (double)(b2-b1)/(k1-k2);
}
double dist2(double a,double b,double c1,double d1,double c,double d){
	if(c==c1){
		if(b<=d1&&b>=d){
			return (c-a)*(c-a);
		}else if(b<=d&&b>=d1){
			return (c-a)*(c-a);
		}else{
			return min(dist(a,b,c,d),dist(a,b,c1,d1));
		}
	}
	if(d==d1){
		if(a<=c1&&a>=c){
			return (d-b)*(d-b);
		}else if(a<=c&&a>=c1){
			return (d-b)*(d-b);
		}else{
			return min(dist(a,b,c,d),dist(a,b,c1,d1));
		}
	}
	double k1=((double)d-d1)/((double)c-c1);
	double k2=-1/k1;
	double b1=(double)d-(c*k1);
	double b2=(double)b-(a*k2);
	double x=j(k1,b1,k2,b2);
	if(x>c1&&x>c){
		return min(dist(a,b,c,d),dist(a,b,c1,d1));
	}
	if(x<c1&&x<c){
		return min(dist(a,b,c,d),dist(a,b,c1,d1));
	}
	return dist(a,b,x,k1*x+b1);
}
int main(){
	int n;double a,b,c,d,c1,d1,c2,d2,min1,max1;
	cin>>n>>a>>b;
	cin>>c>>d;
	c2=c;d2=d;
	min1=max1=(dist(a,b,c,d));
	//cout<<1<<":"<<min1<<endl;
	for(int i=2;i<=n;i++){
		c1=c;d1=d;
		cin>>c>>d;
		double dis=dist2(a,b,c1,d1,c,d);
		//cout<<i<<":"<<dis<<endl;
		if(min1>dis)min1=dis;
		dis=dist(a,b,c,d);
		if(max1<dis)max1=dis;
	}
	double dis=dist2(a,b,c2,d2,c,d);
	//cout<<n+1<<":"<<dis<<endl;
	if(min1>dis)min1=dis;
	dis=dist(a,b,c,d);
	if(max1<dis)max1=dis;
	//cout<<min1<<" "<<max1<<endl;
	cout<<setprecision(15)<<3.141592653589793*(max1-min1);
}


#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
inline double dist(double a,double b,double c,double d){
	return sqrt((a-c)*(a-c)+(b-d)*(b-d));
}
inline double j(double k1,double k2,double b1,double b2){
	return (b2-b1)/(k1-k2);
}
double dist2(int a,int b,int c1,int d1,int c,int d){
	if(c==c1){
		if(b<=d1&&b>=d){
			return abs(c-a);
		}else if(b<=d&&b>=d1){
			return abs(c-a);
		}else{
			return min(dist(a,b,c,d),dist(a,b,c1,d1));
		}
	}
	if(d==d1){
		if(a<=c1&&a>=c){
			return abs(d-b);
		}else if(a<=c&&a>=c1){
			return abs(d-b);
		}else{
			return min(dist(a,b,c,d),dist(a,b,c1,d1));
		}
	}
	double k1=((double)d-d1)/((double)c-c1);
	double k2=-1/k1;
	double b1=(double)d-(c*k1);
	double b2=(double)b-(a*k2);
	double x=j(k1,b1,k2,b2);
	if(x>c1&&x>c){
		return min(dist(a,b,c,d),dist(a,b,c1,d1));
	}
	if(x<c1&&x<c){
		return min(dist(a,b,c,d),dist(a,b,c1,d1));
	}
	return dist(a,b,x,k1*x+b1);
}
int main(){
	int n,a,b,c1,d1,c2,d2;double min1,max1;
	cin>>n>>a>>b;
	int c,d;
	cin>>c>>d;
	c2=c;d2=d;
	min1=max1=(dist(a,b,c,d));
	for(int i=2;i<=n;i++){
		c1=c;d1=d;
		cin>>c>>d;
		double dis=dist2(a,b,c1,d1,c,d);
		//cout<<i<<":"<<dis<<endl;
		if(min1>dis)min1=dis;
		dis=dist(a,b,c,d);
		if(max1<dis)max1=dis;
	}
	double dis=dist2(a,b,c2,d2,c,d);
	//cout<<n+1<<":"<<dis<<endl;
	if(min1>dis)min1=dis;
	dis=dist(a,b,c,d);
	if(max1<dis)max1=dis;
	//cout<<min1<<" "<<max1<<endl;
	cout<<setprecision(15)<<3.141592653589793*(max1*max1-min1*min1);
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <sstream>
#include <cctype>
using namespace std;
#define MAXLEN 200000+10
int main() {
	string s;
	int n;
	int m;
	int sumOne[MAXLEN];
	vector<int> posOne;
	sumOne[0]=0;
	posOne.clear();
	long long res(0);

	cin>>s;
	n=s.size();
	m=sqrt(n);
	for(int i=0;i<n;++i)
	{
		if(s[i]=='1')
		{
			sumOne[i+1]=sumOne[i]+1;
			posOne.push_back(i);
		}
		else
			sumOne[i+1]=sumOne[i];
	}
	if(posOne.size()==0)
	{
		cout<<0<<endl;
		return 0;
	}
	posOne.push_back(n);
	int cntSameNum[n*(m+2)];
	for(int k=1;k<=m;++k)
	{
		long long tmp;
		memset(cntSameNum,0,sizeof(cntSameNum));
		tmp=-1-k*sumOne[0];
		++cntSameNum[tmp+n*k];
		for(int i=0;i<n;++i)
		{
			tmp=i-k*sumOne[i+1];
			res+=cntSameNum[tmp+n*k];
			++cntSameNum[tmp+n*k];
		}
	}
	for(int i=0;i<n;++i)
		for(int j=1;j<=n/m&&sumOne[i]+j<posOne.size();++j)
		{
			int l=posOne[sumOne[i]+j-1]-i+1;
			int r=posOne[sumOne[i]+j]-i+1;
			l=max(l,j*(m+1));
			if(l<r)res+=(r-l+(l-1)%j)/j;
		}
	cout<<res<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <sstream>
#include <cctype>
using namespace std;
#define MAXLEN 200000+10
int main() {
	string s;
	int n;
	int m;
	int sumOne[MAXLEN];
	vector<int> posOne;
	sumOne[0]=0;
	long long res(0);

	cin>>s;
	n=s.size();
	m=sqrt(n);
	for(int i=0;i<n;++i)
	{
		if(s[i]=='1')
		{
			sumOne[i+1]=sumOne[i]+1;
			posOne.push_back(i);
		}
		else
			sumOne[i+1]=sumOne[i];
	}
	if(n>5&&s[0]=='0'&&s[1]=='1'&&s[2]=='0'&&s[3]=='0'&&s[4]=='0')
		cout<<"1"<<endl;
	if(posOne.size()==0)
	{
		cout<<0<<endl;
		return 0;
	}
	posOne.push_back(n);
	int cntSameNum[n*(m+1)];
	for(int k=1;k<=m;++k)
	{
		long long tmp;
		memset(cntSameNum,0,sizeof(cntSameNum));
		tmp=-1-k*sumOne[0];
		++cntSameNum[tmp+n*k];
		for(int i=0;i<n;++i)
		{
			tmp=i-k*sumOne[i+1];
			res+=cntSameNum[tmp+n*k];
			++cntSameNum[tmp+n*k];
		}
	}
	if(n>5&&s[0]=='0'&&s[1]=='1'&&s[2]=='0'&&s[3]=='0'&&s[4]=='0')
		cout<<"2"<<endl;
	for(int i=0;i<n;++i)
		for(int j=1;j<=n/m&&sumOne[i]+j<posOne.size();++j)
		{
			int l=posOne[sumOne[i]+j-1]-i+1;
			int r=posOne[sumOne[i]+j]-i+1;
			l=max(l,j*(m+1));
			if(l<r)res+=(r-l+(l-1)%j)/j;
		}
	cout<<res<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <sstream>
#include <cctype>
using namespace std;
#define MAXLEN 200000+10
int main() {
	string s;
	int n;
	int m;
	int sumOne[MAXLEN];
	vector<int> posOne;
	sumOne[0]=0;
	long long res(0);

	cin>>s;
	n=s.size();
	m=sqrt(n);
	for(int i=0;i<n;++i)
	{
		if(s[i]=='1')
		{
			sumOne[i+1]=sumOne[i]+1;
			posOne.push_back(i);
		}
		else
			sumOne[i+1]=sumOne[i];
	}
	posOne.push_back(n);
	for(int i=0;i<n;++i)
		for(int j=1;j<=posOne.size()&&sumOne[i]+j<posOne.size();++j)
		{
			int l=posOne[sumOne[i]+j-1]-i+1;
			int r=posOne[sumOne[i]+j]-i+1;
			if(l<r)res+=(r-l+(l-1)%j)/j;
		}
	cout<<res<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <sstream>
#include <cctype>
using namespace std;
#define MAXLEN 200000+10
int main() {
	string s;
	int n;
	int m;
	int sumOne[MAXLEN];
	vector<int> posOne;
	sumOne[0]=0;
	long long res(0);

	cin>>s;
	n=s.size();
	m=sqrt(n);
	for(int i=0;i<n;++i)
	{
		if(s[i]=='1')
		{
			sumOne[i+1]=sumOne[i]+1;
			posOne.push_back(i);
		}
		else
			sumOne[i+1]=sumOne[i];
	}
	if(posOne.size()==0)
	{
		cout<<0<<endl;
		return 0;
	}
	posOne.push_back(n);
	vector<int> cntSameNum(n*(m+1));
	for(int k=1;k<=m;++k)
	{
		long long tmp;
		memset(cntSameNum,0,sizeof(cntSameNum));
		tmp=-1;
		++cntSameNum[tmp+n*k];
		for(int i=0;i<n;++i)
		{
			tmp=i-k*sumOne[i+1];
			res+=cntSameNum[tmp+n*k];
			++cntSameNum[tmp+n*k];
		}
	}
	for(int i=0;i<n;++i)
		for(int j=1;j<=n/m&&sumOne[i]+j<posOne.size();++j)
		{
			int l=posOne[sumOne[i]+j-1]-i+1;
			int r=posOne[sumOne[i]+j]-i+1;
			l=max(l,j*(m+1));
			if(l<r)res+=(r-l+(l-1)%j)/j;
		}
	cout<<res<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <sstream>
#include <cctype>
using namespace std;
#define MAXLEN 200000+10
int main() {
	string s;
	int n;
	int m;
	int sumOne[MAXLEN];
	vector<int> posOne;
	sumOne[0]=0;
	long long res(0);

	cin>>s;
	n=s.size();
	m=sqrt(n);
	for(int i=0;i<n;++i)
	{
		if(s[i]=='1')
		{
			sumOne[i+1]=sumOne[i]+1;
			posOne.push_back(i);
		}
		else
			sumOne[i+1]=sumOne[i];
	}
	if(posOne.size()==0)
	{
		cout<<0<<endl;
		return 0;
	}
	posOne.push_back(n);
	vector<int> cntSameNum(n*(m+1));
	for(int k=1;k<=m;++k)
	{
		long long tmp;
		tmp=-1;
		++cntSameNum[tmp+n*k];
		for(int i=0;i<n;++i)
		{
			tmp=i-k*sumOne[i+1];
			res+=cntSameNum[tmp+n*k];
			++cntSameNum[tmp+n*k];
		}

		tmp=-1;
		--cntSameNum[tmp+n*k];
		for(int i=0;i<n;++i)
		{
			tmp=i-k*sumOne[i+1];
			--cntSameNum[tmp+n*k];
		}
	}
	for(int i=0;i<n;++i)
		for(int j=1;j<=n/m&&sumOne[i]+j<posOne.size();++j)
		{
			int l=posOne[sumOne[i]+j-1]-i+1;
			int r=posOne[sumOne[i]+j]-i+1;
			l=max(l,j*(m+1));
			if(l<r)res+=(r-l+(l-1)%j)/j;
		}
	cout<<res<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <sstream>
#include <cctype>
using namespace std;
#define MAXLEN 200000+10
int main() {
	string s;
	int n;
	int m;
	int sumOne[MAXLEN];
	vector<int> posOne;
	while(cin>>s)
	{
		sumOne[0]=0;
		posOne.clear();
		int res(0);

		n=s.size();
		m=sqrt(n);
		for(int i=0;i<n;++i)
		{
			if(s[i]=='1')
			{
				sumOne[i+1]=sumOne[i]+1;
				posOne.push_back(i);
			}
			else
				sumOne[i+1]=sumOne[i];
		}
		if(posOne.size()==0)
		{
			cout<<0<<endl;
			return 0;
		}
		posOne.push_back(n);
		int cntSameNum[MAXLEN];
		for(int k=1;k<=m;++k)
		{
			int tmp;
			memset(cntSameNum,0,sizeof(cntSameNum));
			tmp=-1-k*sumOne[0];
			++cntSameNum[tmp+n*m];
			for(int i=0;i<n;++i)
			{
				tmp=i-k*sumOne[i+1];
				res+=cntSameNum[tmp+n*m];
				++cntSameNum[tmp+n*m];
			}
		}
		for(int i=0;i<n;++i)
			for(int j=1;j<=n/m&&sumOne[i]+j<posOne.size();++j)
			{
				int l=posOne[sumOne[i]+j-1]-i+1;
				int r=posOne[sumOne[i]+j]-i+1;
				l=max(l,j*(m+1));
				if(l<r)res+=(r-l+(l-1)%j)/j;
			}
		cout<<res<<endl;
	}
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <sstream>
#include <cctype>
using namespace std;
#define MAXLEN 200000+10
int main() {
	string s;
	int n;
	int m;
	int sumOne[MAXLEN];
	vector<int> posOne;
	sumOne[0]=0;
	long long res(0);

	cin>>s;
	n=s.size();
	m=sqrt(n);
	for(int i=0;i<n;++i)
	{
		if(s[i]=='1')
		{
			sumOne[i+1]=sumOne[i]+1;
			posOne.push_back(i);
		}
		else
			sumOne[i+1]=sumOne[i];
	}
	cout<<"1"<<endl;
	if(posOne.size()==0)
	{
		cout<<0<<endl;
		return 0;
	}
	posOne.push_back(n);
	int cntSameNum[n*(m+1)];
	for(int k=1;k<=m;++k)
	{
		long long tmp;
		memset(cntSameNum,0,sizeof(cntSameNum));
		tmp=-1-k*sumOne[0];
		++cntSameNum[tmp+n*k];
		for(int i=0;i<n;++i)
		{
			tmp=i-k*sumOne[i+1];
			res+=cntSameNum[tmp+n*k];
			++cntSameNum[tmp+n*k];
		}
	}
	cout<<"2"<<endl;
	for(int i=0;i<n;++i)
		for(int j=1;j<=n/m&&sumOne[i]+j<posOne.size();++j)
		{
			int l=posOne[sumOne[i]+j-1]-i+1;
			int r=posOne[sumOne[i]+j]-i+1;
			l=max(l,j*(m+1));
			if(l<r)res+=(r-l+(l-1)%j)/j;
		}
	cout<<res<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <sstream>
#include <cctype>
using namespace std;
#define MAXLEN 200000+10
int main() {
	string s;
	int n;
	int m;
	int sumOne[MAXLEN];
	vector<int> posOne;
	while(cin>>s)
	{
		sumOne[0]=0;
		posOne.clear();
		int res(0);

		n=s.size();
		m=sqrt(n);
		for(int i=0;i<n;++i)
		{
			if(s[i]=='1')
			{
				sumOne[i+1]=sumOne[i]+1;
				posOne.push_back(i);
			}
			else
				sumOne[i+1]=sumOne[i];
		}
/*		if(posOne.size()==0)
		{
			cout<<0<<endl;
			return 0;
		}*/
		posOne.push_back(n);
		int cntSameNum[n*(m+1)+1];
		for(int k=1;k<=m;++k)
		{
			int tmp;
			memset(cntSameNum,0,sizeof(cntSameNum));
			tmp=-1-k*sumOne[0];
			++cntSameNum[tmp+n*m];
			for(int i=0;i<n;++i)
			{
				tmp=i-k*sumOne[i+1];
				res+=cntSameNum[tmp+n*m];
				++cntSameNum[tmp+n*m];
			}
		}
		for(int i=0;i<n;++i)
			for(int j=1;j<=n/m&&sumOne[i]+j<posOne.size();++j)
			{
				int l=posOne[sumOne[i]+j-1]-i+1;
				int r=posOne[sumOne[i]+j]-i+1;
				l=max(l,j*(m+1));
				if(l<r)res+=(r-l+(l-1)%j)/j;
			}
		cout<<res<<endl;
	}
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <sstream>
#include <cctype>
using namespace std;

#define MAXLEN 200000+10
int main() {
	string s;
	cin>>s;
	int sumOne[MAXLEN]={0};
	for(int i=0;i<s.length();++i)
	{
		if(s[i]=='1')
			sumOne[i+1]=sumOne[i]+1;
		else
			sumOne[i+1]=sumOne[i];
	}
	int res(0);
	map<int,int> ma;
	for(int k=1;k<=s.length();++k)
	{
		ma.clear();
		bool flag=false;
		for(int i=0;i<=s.length();++i)
			++ma[i-k*sumOne[i]];
		for(auto it:ma)
		{
			int tmp=it.second;
			if(tmp>=2)
			{
				flag=true;
				res+=tmp*(tmp-1)/2;
			}
		}
		if(!flag)
			break;
	}
	cout<<res<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <sstream>
#include <cctype>
using namespace std;
#define MAXLEN 200000+10
int main() {
	string s;
	int n;
	int m;
	int sumOne[MAXLEN];
	vector<int> posOne;
	while(cin>>s)
	{
		sumOne[0]=0;
		posOne.clear();
		long long res(0);

		n=s.size();
		m=sqrt(n);
		for(int i=0;i<n;++i)
		{
			if(s[i]=='1')
			{
				sumOne[i+1]=sumOne[i]+1;
				posOne.push_back(i);
			}
			else
				sumOne[i+1]=sumOne[i];
		}
		if(posOne.size()==0)
		{
			cout<<0<<endl;
			return 0;
		}
		posOne.push_back(n);
		int cntSameNum[n*(m+2)];
		for(int k=1;k<=m;++k)
		{
			long long tmp;
			memset(cntSameNum,0,sizeof(cntSameNum));
			tmp=-1-k*sumOne[0];
			++cntSameNum[tmp+n*m];
			for(int i=0;i<n;++i)
			{
				tmp=i-k*sumOne[i+1];
				res+=cntSameNum[tmp+n*m];
				++cntSameNum[tmp+n*m];
			}
		}
		for(int i=0;i<n;++i)
			for(int j=1;j<=n/m&&sumOne[i]+j<posOne.size();++j)
			{
				int l=posOne[sumOne[i]+j-1]-i+1;
				int r=posOne[sumOne[i]+j]-i+1;
				l=max(l,j*(m+1));
				if(l<r)res+=(r-l+(l-1)%j)/j;
			}
		cout<<res<<endl;
	}
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <sstream>
#include <cctype>
using namespace std;
#define MAXLEN 200000+10
int main() {
	string s;
	int n;
	int m;
	int sumOne[MAXLEN];
	vector<int> posOne;
	sumOne[0]=0;
	long long res(0);

	cin>>s;
	n=s.size();
	m=sqrt(n);
	for(int i=0;i<n;++i)
	{
		if(s[i]=='1')
		{
			sumOne[i+1]=sumOne[i]+1;
			posOne.push_back(i);
		}
		else
			sumOne[i+1]=sumOne[i];
	}
	if(posOne.size()==0)
	{
		cout<<0<<endl;
		return 0;
	}
	posOne.push_back(n);
	for(int k=1;k<=m;++k)
	{
		long long tmp;
		vector<int> cntSameNum(n*(m+1));
		tmp=-1;
		++cntSameNum[tmp+n*k];
		for(int i=0;i<n;++i)
		{
			tmp=i-k*sumOne[i+1];
			res+=cntSameNum[tmp+n*k];
			++cntSameNum[tmp+n*k];
		}
	}
	for(int i=0;i<n;++i)
		for(int j=1;j<=n/m&&sumOne[i]+j<posOne.size();++j)
		{
			int l=posOne[sumOne[i]+j-1]-i+1;
			int r=posOne[sumOne[i]+j]-i+1;
			l=max(l,j*(m+1));
			if(l<r)res+=(r-l+(l-1)%j)/j;
		}
	cout<<res<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i--)
#define db double
#define ld long db
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=2e5+5;
char s[N];
int n,sqr,a[N],nxt[N];
ll ans;
map<int,int>M;
signed main(){
	scanf("%s",s+1);n=strlen(s+1);sqr=sqrt(n);
	rep(i,1,n)a[i]=a[i-1]+(s[i]=='1');
	rep(k,1,sqr){
		M.clear();
		M[0]=1;
		rep(i,1,n){
			int re=k*a[i]-i;
			ans+=M[re];M[re]++;
		}
	}
	int last=0;
	rep(i,1,n)if(s[i]=='1')nxt[last]=i,last=i;
	nxt[last]=n+1;nxt[n+1]=n+1;
	rep(len,1,n/sqr){
		int L=0,all=0;
		while(nxt[L]<=n&&all<len)all++,L=nxt[L];
		if(all<len)continue;
		rep(i,1,n){
			if((nxt[L]-i)/len>sqr)ans+=(nxt[L]-i)/len-max(sqr,(L-i)/len);
			if(s[i]=='1')L=nxt[L];
			if(L==n+1)break;
		}
	}
	return cout<<ans,signed();
}


#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i--)
#define db double
#define ld long db
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=2e5+5;
char s[N];
int n,sqr,a[N],nxt[N],M[N*500];
ll ans;
signed main(){
	scanf("%s",s+1);n=strlen(s+1);sqr=sqrt(n);
	rep(i,1,n)a[i]=a[i-1]+(s[i]=='1');
	rep(k,1,sqr){
		M[0]=1;
		rep(i,1,n){
			int re=k*a[i]-i;
			ans+=M[re];M[re]++;
		}
		rep(i,1,n){
			int re=k*a[i]-i;
			M[re]--;
		}
	}
	int last=0;
	rep(i,1,n)if(s[i]=='1')nxt[last]=i,last=i;
	nxt[last]=n+1;nxt[n+1]=n+1;
	rep(len,1,n/sqr){
		int L=0,all=0;
		while(nxt[L]<=n&&all<len)all++,L=nxt[L];
		if(all<len)continue;
		rep(i,1,n){
			if((nxt[L]-i)/len>sqr)ans+=(nxt[L]-i)/len-max(sqr,(L-i)/len);
			if(s[i]=='1')L=nxt[L];
			if(L==n+1)break;
		}
	}
	return cout<<ans,signed();
}


#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i--)
#define db double
#define ld long db
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=2e5+5;
char s[N];
int n,sqr,a[N],nxt[N],M[N*500];
ll ans;
signed main(){
	scanf("%s",s+1);n=strlen(s+1);sqr=sqrt(n);
	rep(i,1,n)a[i]=a[i-1]+(s[i]=='1');
	rep(k,1,sqr){
		M[n]=1;
		rep(i,1,n){
			int re=k*a[i]-i+n;
			ans+=M[re];M[re]++;
		}
		rep(i,1,n){
			int re=k*a[i]-i+n;
			M[re]--;
		}
	}
	int last=0;
	rep(i,1,n)if(s[i]=='1')nxt[last]=i,last=i;
	nxt[last]=n+1;nxt[n+1]=n+1;
	rep(len,1,n/sqr){
		int L=0,all=0;
		while(nxt[L]<=n&&all<len)all++,L=nxt[L];
		if(all<len)continue;
		rep(i,1,n){
			if((nxt[L]-i)/len>sqr)ans+=(nxt[L]-i)/len-max(sqr,(L-i)/len);
			if(s[i]=='1')L=nxt[L];
			if(L==n+1)break;
		}
	}
	return cout<<ans,signed();
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[777];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 777;
	sqr = sqrt(n);
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			int v = i - sum[i] * j;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
	//			printf("%d %d %d %d %d\n",i,j,g[p + i - 1],g[p + i],R / i - (L - 1) / i);
			}
		}
	}
	/*printf("%d %lld\n",sqr,ans);
	for(int i = 1; i <= sqr; i++) {
		printf("****%d：\n",i);
		for(auto it : h[i]) {
			printf("%d %d %d\n",it.first,it.second,sum[it.second]);
		}
	}*/
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr && ll < rr)  ll++;
					ans += ll - l;
			}
	//		printf("xxxxx%d %d %d %d\n",i,l,r,cnt);
		}
	//	printf("*****%d %d\n",i,cnt);
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 201326611;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[250];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 300;
	sqr = min(sqr,n);
	int sqr2 = n / sqr;
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			int v = (1ll * i - 1ll * sum[i] * j % mod) % mod;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr2; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
			}
		}
	}
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr2 && ll < rr) ll++;
					ans += ll - l;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[777],H;
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 777;
	sqr = sqrt(n);
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			int v = i - sum[i] * j;
			//h[j].push_back(pii(v,i));
			H.push_back(pii(v,i));
		}
		//sort(h[j].begin(),h[j].end());
	}
	sort(H.begin(),H.end());
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
	//			printf("%d %d %d %d %d\n",i,j,g[p + i - 1],g[p + i],R / i - (L - 1) / i);
			}
		}
	}
	/*printf("%d %lld\n",sqr,ans);
	for(int i = 1; i <= sqr; i++) {
		printf("****%d：\n",i);
		for(auto it : h[i]) {
			printf("%d %d %d\n",it.first,it.second,sum[it.second]);
		}
	}*/
	/*for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr && ll < rr)  ll++;
					ans += ll - l;
			}
		}
	}*/
		for(int l = 0,r; l < H.size(); l = r + 1) {
			r = l;
			while(r + 1 < H.size() && H[r].first == H[r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[H[rr].second] - sum[H[ll].second] > sqr && ll < rr)  ll++;
					ans += ll - l;
			}
		}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 201326611;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[250];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 200;
	sqr = min(sqr,n);
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			ll v = (1ll * i - 1ll * sum[i] * j) % mod;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
	//			printf("%d %d %d %d %d\n",i,j,g[p + i - 1],g[p + i],R / i - (L - 1) / i);
			}
		}
	}
	/*printf("%d %lld\n",sqr,ans);
	for(int i = 1; i <= sqr; i++) {
		printf("****%d：\n",i);
		for(auto it : h[i]) {
			printf("%d %d %d\n",it.first,it.second,sum[it.second]);
		}
	}*/
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr && ll < rr)  ll++;
					ans += ll - l;
			}
	//		printf("xxxxx%d %d %d %d\n",i,l,r,cnt);
		}
	//	printf("*****%d %d\n",i,cnt);
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[777];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 200;
	sqr = min(sqr,n);
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			int v = i - sum[i] * j;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
	//			printf("%d %d %d %d %d\n",i,j,g[p + i - 1],g[p + i],R / i - (L - 1) / i);
			}
		}
	}
	/*printf("%d %lld\n",sqr,ans);
	for(int i = 1; i <= sqr; i++) {
		printf("****%d：\n",i);
		for(auto it : h[i]) {
			printf("%d %d %d\n",it.first,it.second,sum[it.second]);
		}
	}*/
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr && ll < rr)  ll++;
					ans += ll - l;
			}
	//		printf("xxxxx%d %d %d %d\n",i,l,r,cnt);
		}
	//	printf("*****%d %d\n",i,cnt);
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 201326611;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[450];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 400;
	sqr = min(sqr,n);
	int sqr2 = n / sqr;
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			int v = (1ll * i - 1ll * sum[i] * j % mod) % mod;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr2; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
			}
		}
	}
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr2 && ll < rr) ll++;
					ans += ll - l;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 201326611;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[450];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 300;
	sqr = min(sqr,n);
	int sqr2 = n / sqr;
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			int v = (1ll * i - 1ll * sum[i] * j % mod) % mod;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr2; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
			}
		}
	}
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr2 && ll < rr) ll++;
					ans += ll - l;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 201326611;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[250];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 200;
	sqr = min(sqr,n);
	int sqr2 = n / sqr;
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			int v = (1ll * i - 1ll * sum[i] * j % mod) % mod;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr2; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
			}
		}
	}
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr2 && ll < rr) ll++;
					ans += ll - l;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[1000];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 777;
	sqr = sqrt(n);
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			int v = i - sum[i] * j;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
	//			printf("%d %d %d %d %d\n",i,j,g[p + i - 1],g[p + i],R / i - (L - 1) / i);
			}
		}
	}
	/*printf("%d %lld\n",sqr,ans);
	for(int i = 1; i <= sqr; i++) {
		printf("****%d：\n",i);
		for(auto it : h[i]) {
			printf("%d %d %d\n",it.first,it.second,sum[it.second]);
		}
	}*/
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr && ll < rr)  ll++;
					ans += ll - l;
			}
	//		printf("xxxxx%d %d %d %d\n",i,l,r,cnt);
		}
	//	printf("*****%d %d\n",i,cnt);
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[450];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = sqrt(n);
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			int v = i - sum[i] * j;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
			}
		}
	}
	g.clear();
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr && ll < rr)  ll++;
					ans += ll - l;
			}
		}
	}
	/*for(int l = 0,r; l < H.size(); l = r + 1) {
		r = l;
		while(r + 1 < H.size() && H[r].first == H[r + 1].first) r++;
		int ll = l;
		for(int rr = l; rr <= r; rr++) {
			while(sum[H[rr].second] - sum[H[ll].second] > sqr && ll < rr)  ll++;
				ans += ll - l;
		}
	}*/
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 201326611;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[250];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 200;
	sqr = min(sqr,n);
	int sqr2 = n / sqr;
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			int v = (1ll * i - 1ll * sum[i] * j % mod) % mod;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr2; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
			}
		}
	}
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr && ll < rr) ll++;
					ans += ll - l;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
#define pii pair<ll,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[250];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 200;
	sqr = min(sqr,n);
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			ll v = 1ll * i - 1ll * sum[i] * j;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
	//			printf("%d %d %d %d %d\n",i,j,g[p + i - 1],g[p + i],R / i - (L - 1) / i);
			}
		}
	}
	/*printf("%d %lld\n",sqr,ans);
	for(int i = 1; i <= sqr; i++) {
		printf("****%d：\n",i);
		for(auto it : h[i]) {
			printf("%d %d %d\n",it.first,it.second,sum[it.second]);
		}
	}*/
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr && ll < rr)  ll++;
					ans += ll - l;
			}
	//		printf("xxxxx%d %d %d %d\n",i,l,r,cnt);
		}
	//	printf("*****%d %d\n",i,cnt);
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[777];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 300;
	sqr = min(sqr,n);
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			int v = i - sum[i] * j;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
	//			printf("%d %d %d %d %d\n",i,j,g[p + i - 1],g[p + i],R / i - (L - 1) / i);
			}
		}
	}
	/*printf("%d %lld\n",sqr,ans);
	for(int i = 1; i <= sqr; i++) {
		printf("****%d：\n",i);
		for(auto it : h[i]) {
			printf("%d %d %d\n",it.first,it.second,sum[it.second]);
		}
	}*/
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr && ll < rr)  ll++;
					ans += ll - l;
			}
	//		printf("xxxxx%d %d %d %d\n",i,l,r,cnt);
		}
	//	printf("*****%d %d\n",i,cnt);
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
#define pii pair<ll,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[250];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 230;
	sqr = min(sqr,n);
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			ll v = 1ll * i - 1ll * sum[i] * j;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
	//			printf("%d %d %d %d %d\n",i,j,g[p + i - 1],g[p + i],R / i - (L - 1) / i);
			}
		}
	}
	/*printf("%d %lld\n",sqr,ans);
	for(int i = 1; i <= sqr; i++) {
		printf("****%d：\n",i);
		for(auto it : h[i]) {
			printf("%d %d %d\n",it.first,it.second,sum[it.second]);
		}
	}*/
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr && ll < rr)  ll++;
					ans += ll - l;
			}
	//		printf("xxxxx%d %d %d %d\n",i,l,r,cnt);
		}
	//	printf("*****%d %d\n",i,cnt);
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
//vector<pii> h[450];
pii h[450][maxn];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = sqrt(n);
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			int v = i - sum[i] * j;
			h[j][i] = pii(v,i);
			//h[j].push_back(pii(v,i));
		}
		sort(h[j],h[j] + n + 1);
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
			}
		}
	}
	g.clear();
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l <= n; l = r + 1) {
			r = l;
			while(r + 1 <= n && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr && ll < rr)  ll++;
					ans += ll - l;
			}
		}
	}
	/*for(int l = 0,r; l < H.size(); l = r + 1) {
		r = l;
		while(r + 1 < H.size() && H[r].first == H[r + 1].first) r++;
		int ll = l;
		for(int rr = l; rr <= r; rr++) {
			while(sum[H[rr].second] - sum[H[ll].second] > sqr && ll < rr)  ll++;
				ans += ll - l;
		}
	}*/
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 201326611;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[450];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 250;
	sqr = min(sqr,n);
	int sqr2 = n / sqr;
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			int v = (1ll * i - 1ll * sum[i] * j % mod) % mod;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr2; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
			}
		}
	}
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr2 && ll < rr) ll++;
					ans += ll - l;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[1000];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 777;
	sqr = sqrt(n);
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 1; i <= n; i++) {
			int v = i - sum[i] * j;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
	//			printf("%d %d %d %d %d\n",i,j,g[p + i - 1],g[p + i],R / i - (L - 1) / i);
			}
		}
	}
	/*printf("%d %lld\n",sqr,ans);
	for(int i = 1; i <= sqr; i++) {
		printf("****%d：\n",i);
		for(auto it : h[i]) {
			printf("%d %d %d\n",it.first,it.second,sum[it.second]);
		}
	}*/
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first)	 r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] >= sqr && ll < rr) ll++;
				if(sum[h[i][rr].second] - sum[h[i][ll].second] <= sqr)
					ans += ll - l;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
#define pii pair<ll,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[250];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 180;
	sqr = min(sqr,n);
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			ll v = 1ll * i - 1ll * sum[i] * j;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
	//			printf("%d %d %d %d %d\n",i,j,g[p + i - 1],g[p + i],R / i - (L - 1) / i);
			}
		}
	}
	/*printf("%d %lld\n",sqr,ans);
	for(int i = 1; i <= sqr; i++) {
		printf("****%d：\n",i);
		for(auto it : h[i]) {
			printf("%d %d %d\n",it.first,it.second,sum[it.second]);
		}
	}*/
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr && ll < rr)  ll++;
					ans += ll - l;
			}
	//		printf("xxxxx%d %d %d %d\n",i,l,r,cnt);
		}
	//	printf("*****%d %d\n",i,cnt);
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[450];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	sqr = sqrt(n);
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			int v = i - sum[i] * j;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
			}
		}
	}
	g.clear();
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr && ll < rr)  ll++;
					ans += ll - l;
			}
		}
	}
	/*for(int l = 0,r; l < H.size(); l = r + 1) {
		r = l;
		while(r + 1 < H.size() && H[r].first == H[r + 1].first) r++;
		int ll = l;
		for(int rr = l; rr <= r; rr++) {
			while(sum[H[rr].second] - sum[H[ll].second] > sqr && ll < rr)  ll++;
				ans += ll - l;
		}
	}*/
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 201326611;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[450];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 250;
	sqr = min(sqr,n);
	int sqr2 = n / sqr;
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			int v = (1ll * i - 1ll * sum[i] * j % mod) % mod;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr2; i++) {				//1的个数
		int p = 0;
		for(int j = 1; j <= n; j++) {
			while(p < g.size() && g[p] < j) p++;
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
			}
		}
	}
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr2 && ll < rr) ll++;
					ans += ll - l;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 201326611;
#define pii pair<int,int>
typedef long long ll;
int n,sum[maxn];
char s[maxn];
vector<int> g;
vector<pii> h[250];
int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') g.push_back(i);
		if(s[i] == '1') sum[i] = 1;
		else sum[i] = 0;
	}
	g.push_back(n+1);
	int sqr = 200;
	sqr = min(sqr,n);
	for(int i = 1; i <= n; i++)
		sum[i] += sum[i - 1];
	for(int j = 1; j <= sqr; j++)  {
		for(int i = 0; i <= n; i++) {
			int v = (1ll * i - 1ll * sum[i] * j % mod) % mod;
			h[j].push_back(pii(v,i));
		}
		sort(h[j].begin(),h[j].end());
	}
	ll ans = 0,cnt = 0;
	for(int i = 1; i <= sqr; i++) {				//1的个数
		for(int j = 1; j <= n; j++) {
			int p = lower_bound(g.begin(),g.end(),j) - g.begin();
			if(p >= g.size()) continue;
			if(p + i < g.size()) {
				int L = g[p + i - 1] - j + 1,R = g[p + i] - j;
				ans += R / i - (L - 1) / i;
	//			printf("%d %d %d %d %d\n",i,j,g[p + i - 1],g[p + i],R / i - (L - 1) / i);
			}
		}
	}
	/*printf("%d %lld\n",sqr,ans);
	for(int i = 1; i <= sqr; i++) {
		printf("****%d：\n",i);
		for(auto it : h[i]) {
			printf("%d %d %d\n",it.first,it.second,sum[it.second]);
		}
	}*/
	for(int i = 1; i <= sqr; i++) {
		int cnt = 0;
		for(int l = 0,r; l < h[i].size(); l = r + 1) {
			r = l;
			while(r + 1 < h[i].size() && h[i][r].first == h[i][r + 1].first) r++;
			int ll = l;
			for(int rr = l; rr <= r; rr++) {
				while(sum[h[i][rr].second] - sum[h[i][ll].second] > sqr && ll < rr)  ll++;
					ans += ll - l;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


#include <bits/stdc++.h>
#define dbg() cerr <<
#define name(x) (#x) << ": " << (x) << ' ' <<

using namespace std;

const int MAX = 444;

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

  string s; getline(cin, s);
  int n = s.size();
  vector<int> pref(n), fst_pos(n + 1, -1);
  for (int i = 0; i < n; ++i) {
    pref[i] = s[i] - '0';
    if (i != 0) {
      pref[i] += pref[i - 1];
    }
    if (s[i] == '1') {
      fst_pos[pref[i]] = i;
    }
  }
  long long ans = 0LL;
  vector<int> freq(n * MAX + n);
  for (int k = 1; k <= MAX; ++k) {
    freq[n + 1] = 1;
    for (int i = 0; i < n; ++i) {
      int x = k * pref[i] - i + n;
      ans += freq[x];
      ++freq[x];
    }
    for (int i = 0; i < n; ++i) {
      int x = k * pref[i] - i + n;
      freq[x] -= 1;
    }
  }

  for (int l = -1; l < n; ++l) {
    for (int cnt = 1; cnt * MAX <= n; ++cnt) {
      if ((l == -1 ? 0 : pref[l]) + cnt + 1 > n) break;
      int lo, hi;
      if (l != -1) {
        lo = fst_pos[pref[l] + cnt];
        hi = fst_pos[pref[l] + cnt + 1] - 1;
      } else {
        lo = fst_pos[cnt];
        hi = fst_pos[cnt + 1];
      }
      if (lo == -1 || hi == -1) break;
      lo = max(lo, l + cnt * (MAX + 1));
      if (lo <= hi) {
        ans += ((hi - l) / cnt - (lo - l) / cnt + 1);
      }
    }
  }
  cout << ans << endl;
}


#include <bits/stdc++.h>
#define dbg() cerr <<
#define name(x) (#x) << ": " << (x) << ' ' <<

using namespace std;

const int MAX = 444;

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

  string s; getline(cin, s);
  int n = s.size();
  vector<int> pref(n), fst_pos(n + 1, -1);
  for (int i = 0; i < n; ++i) {
    pref[i] = s[i] - '0';
    if (i != 0) {
      pref[i] += pref[i - 1];
    }
    if (s[i] == '1') {
      fst_pos[pref[i]] = i;
    }
  }
  long long ans = 0LL;
  vector<int> freq(n * MAX + n);
  for (int k = 1; k <= MAX; ++k) {
    freq[n + 1] = 1;
    for (int i = 0; i < n; ++i) {
      int x = k * pref[i] - i + n;
      ans += freq[x];
      ++freq[x];
    }
    for (int i = 0; i < n; ++i) {
      int x = k * pref[i] - i + n;
      freq[x] -= 1;
    }
  }

  for (int l = 0; l < n; ++l) {
    for (int cnt = 1; cnt * MAX <= n; ++cnt) {
      int lo = fst_pos[pref[l] + cnt];
      int hi = fst_pos[pref[l] + cnt + 1] - 1;
      if (lo == -1 || hi == -1) break;
      lo = max(lo, l + cnt * (MAX + 1));
      if (lo <= hi) {
        ans += ((hi - l) / cnt - (lo - l) / cnt + 1);
      }
    }
  }
  cout << ans << endl;

  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}


#include <bits/stdc++.h>
#define dbg() cerr <<
#define name(x) (#x) << ": " << (x) << ' ' <<

using namespace std;

const int MAX = 444;

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

  string s; getline(cin, s);
  int n = s.size();
  vector<int> pref(n), fst_pos(n + 2, -1);
  for (int i = 0; i < n; ++i) {
    pref[i] = s[i] - '0';
    if (i != 0) {
      pref[i] += pref[i - 1];
    }
    if (s[i] == '1') {
      fst_pos[pref[i]] = i;
    }
  }
  fst_pos[pref[n - 1] + 1] = n;
  long long ans = 0LL;
  vector<int> freq(n * MAX + n);
  for (int k = 1; k <= MAX; ++k) {
    freq[n + 1] = 1;
    for (int i = 0; i < n; ++i) {
      int x = k * pref[i] - i + n;
      ans += freq[x];
      ++freq[x];
    }
    for (int i = 0; i < n; ++i) {
      int x = k * pref[i] - i + n;
      freq[x] -= 1;
    }
  }

  for (int l = -1; l < n; ++l) {
    for (int cnt = 1; cnt * MAX <= n; ++cnt) {
      if ((l == -1 ? 0 : pref[l]) + cnt + 1 > n + 1) break;
      int lo, hi;
      if (l != -1) {
        lo = fst_pos[pref[l] + cnt];
        hi = fst_pos[pref[l] + cnt + 1] - 1;
      } else {
        lo = fst_pos[cnt];
        hi = fst_pos[cnt + 1] - 1;
      }
      if (lo == -1 || hi == -1) break;
      lo = max(lo, l + cnt * (MAX + 1));
      // dbg() name(l) name(cnt) name(lo) name(hi) name((hi - l) / cnt - (lo - l) / cnt + 1) endl;
      if (lo <= hi) {
        ans += ((hi - l) / cnt - (lo - l - 1) / cnt);
      }
    }
  }
  cout << ans << endl;
}


#include <bits/stdc++.h>
#define dbg() cerr <<
#define name(x) (#x) << ": " << (x) << ' ' <<

using namespace std;

const int MAX = 444;

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

  string s; getline(cin, s);
  int n = s.size();
  vector<int> pref(n), fst_pos(n + 1, -1);
  for (int i = 0; i < n; ++i) {
    pref[i] = s[i] - '0';
    if (i != 0) {
      pref[i] += pref[i - 1];
    }
    if (s[i] == '1') {
      fst_pos[pref[i]] = i;
    }
  }
  long long ans = 0LL;
  vector<int> freq(n * MAX + MAX);
  for (int k = 1; k <= MAX; ++k) {
    freq[MAX + 1] = 1;
    for (int i = 0; i < n; ++i) {
      int x = k * pref[i] - i + MAX;
      ans += freq[x];
      ++freq[x];
    }
    for (int i = 0; i < n; ++i) {
      int x = k * pref[i] - i + MAX;
      freq[x] -= 1;
    }
  }

  for (int l = 0; l < n; ++l) {
    for (int cnt = 1; cnt * MAX <= n; ++cnt) {
      int lo = fst_pos[pref[l] + cnt];
      int hi = fst_pos[pref[l] + cnt + 1] - 1;
      lo = max(lo, l + cnt * (MAX + 1));
      if (lo <= hi) {
        ans += ((hi - l) / cnt - (lo - l) / cnt + 1);
      }
    }
  }
  cout << ans << endl;

  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}


#include<bits/stdc++.h>
#define	LL long long
using namespace std;
const int N = 200050,Lim = 100;
string st;
int n,a[N]; LL ans;
map<LL,int>mp;
inline void solve1(int k){
	int i; LL v;
	mp.clear();
	for (i = 0; i <= n; ++i){ v = i - 1ll * k * a[i]; if (!mp.count(v)) mp[v] = 1; else ans += mp[v],mp[v]++; }
}
int m,L[N],R[N];
int main(){
	int i,l,c;
	cin >> st; n = st.size();
	for (i = 1; i <= n; ++i) a[i] = a[i-1] + st[i-1] - '0';
	for (i = 1; i <= Lim; ++i) solve1(i);
	m = 0; L[0] = R[0] = 1;
	for (i = 1; i <= n; ++i){
		if (st[i-1] == '0'){ R[m] = i; continue; }
		++m; L[m] = R[m] = i;
	}
	int Lim2 = n / Lim;
	int ll,rr;
	for (l = 1; l <= n; ++l){
		for (c = 1; c <= Lim2; ++c){
			if (c+a[l-1] > m) break;
			ll = L[c+a[l-1]],rr = R[c+a[l-1]];
			ll = max(ll,l);
			ll -= l-1,rr -= l-1;
			ll = max(Lim+1,ll / c + (ll % c ? 1 : 0));
			rr /= c;
			if (ll <= rr) ans += rr - ll + 1;
		}
	}
	cout << ans << '\n';
	return 0;
}


#include<bits/stdc++.h>
#define	LL long long
using namespace std;
const int N = 200050,Lim = 200;
string st;
int n,a[N]; LL ans;
map<LL,int>mp;
inline void solve1(int k){
	int i; LL v;
	mp.clear();
	for (i = 0; i <= n; ++i){ v = i - 1ll * k * a[i]; if (!mp.count(v)) mp[v] = 1; else ans += mp[v],mp[v]++; }
}
int m,L[N],R[N];
int main(){
	int i,l,c;
	cin >> st; n = st.size();
	for (i = 1; i <= n; ++i) a[i] = a[i-1] + st[i-1] - '0';
	for (i = 1; i <= Lim; ++i) solve1(i);
	m = 0; L[0] = R[0] = 1;
	for (i = 1; i <= n; ++i){
		if (st[i-1] == '0'){ R[m] = i; continue; }
		++m; L[m] = R[m] = i;
	}
	int Lim2 = n / Lim;
	int ll,rr;
	for (l = 1; l <= n; ++l){
		for (c = 1; c <= Lim2; ++c){
			ll = L[c+a[l-1]],rr = R[c+a[l-1]];
			ll -= l,rr -= l;
			++ll,++rr;
			if (ll % c == 0) ll = ll / c; else ll = ll / c + 1;
			if (rr % c == 0) rr = rr / c; else rr = rr / c;
			if (ll <= rr) ans += rr - ll + 1;
		}
	}
	cout << ans << '\n';
	return 0;
}


#include<bits/stdc++.h>
#define	LL long long
using namespace std;
const int N = 200050,Lim = 200;
string st;
int n,a[N]; LL ans;
map<LL,int>mp;
inline void solve1(int k){
	int i; LL v;
	mp.clear();
	for (i = 0; i <= n; ++i){ v = i - 1ll * k * a[i]; if (!mp.count(v)) mp[v] = 1; else ans += mp[v],mp[v]++; }
}
int m,L[N],R[N];
int main(){
	int i,l,c;
	cin >> st; n = st.size();
	for (i = 1; i <= n; ++i) a[i] = a[i-1] + st[i-1] - '0';
	for (i = 1; i <= Lim; ++i) solve1(i);
	m = 0; L[0] = R[0] = 1;
	for (i = 1; i <= n; ++i){
		if (st[i-1] == '0'){ R[m] = i; continue; }
		++m; L[m] = R[m] = i;
	}
	int Lim2 = n / Lim;
	int ll,rr;
	for (l = 1; l <= n; ++l){
		for (c = 1; c <= Lim2; ++c){
			if (c+a[l-1] > m) break;
			ll = L[c+a[l-1]],rr = R[c+a[l-1]];
			ll = max(ll,l);
			ll -= l-1,rr -= l-1;
			if (ll % c == 0) ll = ll / c; else ll = ll / c + 1;
			if (rr % c == 0) rr = rr / c; else rr = rr / c;
			ll = max(ll,Lim+1);
			if (ll <= rr) ans += rr - ll + 1;
		}
	}
	cout << ans << '\n';
	return 0;
}


#include<bits/stdc++.h>
#define	LL long long
using namespace std;
const int N = 200050,Lim = 500;
string st;
int n,a[N]; LL ans;
int cnt[N*(Lim+7)];
inline void solve1(int k){
	int i; LL x; vector<LL>v;
	for (i = 0; i <= n; ++i) x = 1ll*k*a[i]-i+n,++cnt[x],v.push_back(x);
	while (v.size()) x = v[v.size()-1],ans += 1ll * cnt[x] * (cnt[x]-1) / 2,cnt[x] = 0,v.pop_back();
}
int m,L[N],R[N];
int main(){
	int i,l,c;
	cin >> st; n = st.size();
	for (i = 1; i <= n; ++i) a[i] = a[i-1] + st[i-1] - '0';
	for (i = 1; i <= Lim; ++i) solve1(i);
	m = 0; L[0] = R[0] = 1;
	for (i = 1; i <= n; ++i){
		if (st[i-1] == '0'){ R[m] = i; continue; }
		++m; L[m] = R[m] = i;
	}
	int Lim2 = n / Lim;
	int ll,rr;
	for (l = 1; l <= n; ++l){
		for (c = 1; c <= Lim2; ++c){
			if (c+a[l-1] > m) break;
			ll = L[c+a[l-1]],rr = R[c+a[l-1]];
			ll = max(ll,l);
			ll -= l-1,rr -= l-1;
			ll = max(Lim+1,ll / c + (ll % c ? 1 : 0));
			rr /= c;
			if (ll <= rr) ans += rr - ll + 1;
		}
	}
	cout << ans << '\n';
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define Maxn 200007
#define T 357
char s[Maxn];
int a[Maxn],pre[Maxn],pos[Maxn];
int que[Maxn];
int n,m=0;
long long ans=0LL;
int calc(int n,int a,int b)
{
    return max(0,(n-T*b-a)/b);
}
int calc(int lx,int rx,int a,int b)
{
    return calc(rx,a,b)-calc(lx-1,a,b);
}
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for (int i=1;i<=n;i++)
    {
        a[i]=s[i]-'0';
        if (a[i]==1) pos[++m]=i;
        pre[i]=pre[i-1]+a[i];
    }
    pos[m+1]=n+1;
    for (int k=1;k<=T&&k<=n;k++)
    {
        for (int i=0;i<=n;i++)
            que[i]=i-k*pre[i];
        sort(que,que+n+1);
        int now=1;
        for (int i=1;i<=n;i++)
        {
            if (que[i]==que[i-1])
            {
                ans+=now;
                ++now;
            } else now=1;
        }
    }
    for (int i=1;i<=n/T;i++)
    {
        for (int l=0;l<n;l++)
            if (pre[l]+i<=m) ans+=calc(pos[pre[l]+i],pos[pre[l]+i+1]-1,l,i);
    }
    printf("%lld\n",ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define Maxn 200007
#define T 357
char s[Maxn];
int a[Maxn],pre[Maxn],pos[Maxn];
int que[Maxn];
int n,m=0;
long long ans=0LL;
int calc(int n,int a,int b)
{
    return max(0,(n-T*b-a)/b);
}
int calc(int lx,int rx,int a,int b)
{
    return calc(rx,a,b)-calc(lx-1,a,b);
}
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for (int i=1;i<=n;i++)
    {
        a[i]=s[i]-'0';
        if (a[i]==1) pos[++m]=i;
        pre[i]=pre[i-1]+a[i];
    }
    pos[m+1]=n+1;
    for (int k=1;k<=T&&k<=n;k++)
    {
        for (int i=0;i<=n;i++)
            que[i]=i-k*pre[i];
        sort(que,que+n+1);
        int now=1;
        for (int i=1;i<=n;i++)
        {
            if (que[i]==que[i-1])
            {
                ans+=now;
                ++now;
            } else now=1;
        }
    }
    for (int i=1;i<=n/T;i++)
    {
        for (int l=0;l<n;l++)
            ans+=calc(pos[pre[l]+i],pos[pre[l]+i+1]-1,l,i);
    }
    printf("%lld\n",ans);
    return 0;
}


#include<bits/stdc++.h>
#define R register
#define N 1000001
#define ll long long

ll ans;
char s[N];
int a[N],S;
int stk[N],top,n;

namespace hash{
	const int fk=39079907;
	int qz[fk],stk[fk],top;
	bool vis[fk];

	inline void clr(){
		while(top) qz[stk[top]]=vis[stk[top]]=0,--top;
	}

	inline ll getans(){
		R ll ans=0;
		for(R int i=1;i<=top;++i) ans=(ans+qz[stk[i]]*(qz[stk[i]]-1)/2);
		return ans;
	}

	inline void add_k(int x){
		if(!vis[x]) vis[x]=1,stk[++top]=x; ++qz[x];
	}
}

int main(){
	scanf("%s",s+1);n=strlen(s+1),S=(int)sqrt(n)+1;
	if(n<=1000){
		for(R int i=1;i<=n;++i){
			int sb=0;
			for(R int j=i;j<=n;++j){
				sb+=(s[j]=='1'); if((j-i+1)%sb==0) ++ans;
			}
		} std::cout<<ans<<"\n"; return 0;
	}
	for(R int i=1;i<=n;++i){
		if(s[i]=='1') stk[++top]=i;
		for(R int j=1;j<=S;++j){
			R int l=i-stk[top-j+1]+1,r=i-stk[top-j]; l=std::max(l,(S+1)*j);
			if(l>r) continue; ans+=r/j-(l-1)/j;
		}
	}
	for(R int i=1;i<=S;++i){
		hash::clr();
		R int mn=(int)2e9;
		for(R int j=1;j<=n;++j) a[j]=(s[j]=='1'?(i-1):(-1)),a[j]+=a[j-1],mn=std::min(mn,a[j]);
		for(R int j=0;j<=n;++j) hash::add_k(a[j]-mn);ans+=hash::getans();
	} std::cout<<ans;
}


#include <cmath>
#include <cstdio>
#include <cstring>

typedef long long LL;

const int MAXN = 2e5 + 5, MAXT = 505;

template<typename _T>
void read( _T &x )
{
	x = 0;char s = getchar();int f = 1;
	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}
	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}
	x *= f;
}

template<typename _T>
void write( _T x )
{
	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }
	if( 9 < x ){ write( x / 10 ); }
	putchar( x % 10 + '0' );
}

template<typename _T>
_T MAX( const _T a, const _T b )
{
	return a > b ? a : b;
}

int buc[MAXN * MAXT];
int s[MAXN], nxt[MAXN];
int N, T;
char S[MAXN];

int main()
{
	LL ans = 0;
	scanf( "%s", S + 1 ), N = strlen( S + 1 ), T = ceil( sqrt( N ) );
	for( int i = 1 ; i <= N ; i ++ ) s[i] = s[i - 1] + S[i] - '0';
	if( s[N] == 0 ) { puts( "0" ); return 0; }
	for( int i = N ; ~ i ; i -- )
	{
		if( s[i] ^ s[i + 1] ) nxt[i] = i + 1;
		else nxt[i] = nxt[i + 1];
	}
	for( int k = 1, t ; k <= T ; k ++ )
	{
		for( int i = 0 ; i <= N ; i ++ ) buc[s[i] * k - i + N] ++;
		for( int i = 0 ; i <= N ; i ++ ) t = buc[s[i] * k - i + N], ans += 1ll * t * ( t - 1 ) / 2, buc[s[i] * k - i + N] = 0;
	}
	int l, r, tl, tr;
	for( int i = 0 ; i < N ; i ++ )
	{
		l = i, r = nxt[i];
		for( int k = 1 ; k <= N / T && s[i] + k <= s[N] ; k ++ )
		{
			l = nxt[l], r = nxt[r];
			tr = r - i - 1, tl = l - i;
			tl = MAX( tl, k * T + 1 );
			if( tl <= tr ) ans += tr / k - ( tl - 1 ) / k;
		}
	}
	write( ans ), putchar( '\n' );
	return 0;
}


#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=200002;
typedef long long ll;
int n,i,j,k,m,D,g[N],cnt[N*450];
int S,l,r,sum[N];
ll Ans;
char s[N];
void init(){
	scanf("%s",s+1);
	while(s[n+1])n++;
}
void work(){
	D=(int)(sqrt(n)+1);
	for(k=1;k<=D;k++){
		S=n*k;cnt[S]++;
		for(i=1;i<=n;i++){
			S++;
			if(s[i]=='1')
				S-=k;
			Ans+=cnt[S];
			cnt[S]++;
		}
		S=n*k;cnt[S]=0;
		for(i=1;i<=n;i++){
			S++;
			if(s[i]=='1')
				S-=k;
			cnt[S]=0;
		}
	}
	for(i=1;i<=n;i++)
		sum[i]=sum[i-1]+(s[i]=='1');
	for(k=1;k<=D+1;k++){
		l=r=0;
		for(i=0;i<=n;i++){
			if(sum[n]-sum[i]<k)break;
			while(r<n&&sum[r+1]-sum[i]<=k)r++;
			while(l<n&&sum[l+1]-sum[i]<k)l++;
			Ans+=max(0,(r-i)/k-max((l-i)/k,D));
		}
		//printf("   %d %d\n",l,r);
	}
	printf("%lld",Ans);
}
int main(){
	init();
	work();
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
#define N 200002
typedef long long ll;
char ch[N];
int n,s[N],blk,pre[N],nxt[N],a[N],c[10000002],b[N],tot;
bool vis[10000002];
const int bas=1004535809,p=9999799;
int main()
{
	scanf("%s",ch+1);n=strlen(ch+1);blk=sqrt(n);if(blk*blk<n)blk++;
	for(int i=1;i<=n;i++)s[i]=s[i-1]+ch[i]-'0',nxt[i]=n+1;
	int la=0;
	for(int i=1;i<=n;i++)
	{
		pre[i]=la,nxt[la]=i;
		if(ch[i]=='1')la=i;
	}la=n+1;
	for(int i=n;i;i--)
	{
		if(ch[i]=='1')la=i;
		else nxt[i]=la;
	}
	//printf("%d blk\n",blk);
	ll ans=0;
	for(int i=1;i<=blk;i++)
	{tot=0;
		for(int j=0;j<=n;j++)
		{
			int val=(j-i*s[j]+bas)%p;
			c[val]++;
			if(!vis[val])
			{
				b[++tot]=val;vis[val]=1;
			}
		}
		for(int j=1;j<=tot;j++)ans+=1ll*c[b[j]]*(c[b[j]]-1)/2,vis[b[j]]=c[b[j]]=0;
	}
	//printf("%lld\n",ans);
	for(int i=1;i<=blk+3;i++)
	{
		int l=nxt[1],r;
		for(r=nxt[1];r<=n;r++)
		{
			while(s[r]-s[l-1]>i&&l<=r)l=nxt[l];
			int ss=s[r]-s[l-1];
			if(ss==i)
			{
				int pr=pre[l]+1;
				ll mn=ss*(blk+1),mx=(r-pr+1)/ss*ss;
				ll val=(r-l+1)/ss*ss;if((r-l+1)%ss)val+=ss;
				mn=max(mn,val);
				if(mn<=mx)ans+=1ll*(mx-mn)/ss+1;
			}
		}
	}
	printf("%I64d\n",ans);
}
//0000000100 24


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
#define N 200002
typedef long long ll;
char ch[N];
int n,s[N],blk,pre[N],nxt[N],a[N],c[10000002],b[N],tot;
bool vis[10000002];
const ll bas=1004535809,p=9999797;
int main()
{
	scanf("%s",ch+1);n=strlen(ch+1);blk=sqrt(n);if(blk*blk<n)blk++;
	for(int i=1;i<=n;i++)s[i]=s[i-1]+ch[i]-'0',nxt[i]=n+1;
	int la=0;
	for(int i=1;i<=n;i++)
	{
		pre[i]=la,nxt[la]=i;
		if(ch[i]=='1')la=i;
	}la=n+1;
	for(int i=n;i;i--)
	{
		if(ch[i]=='1')la=i;
		else nxt[i]=la;
	}
	//printf("%d blk\n",blk);
	ll ans=0;
	for(int i=1;i<=blk;i++)
	{tot=0;
		for(int j=0;j<=n;j++)
		{
			int val=(j-i*s[j]+bas)%p;
			c[val]++;
			if(!vis[val])
			{
				b[++tot]=val;vis[val]=1;
			}
		}
		for(int j=1;j<=tot;j++)ans+=1ll*c[b[j]]*(c[b[j]]-1)/2,vis[b[j]]=c[b[j]]=0;
	}
	//printf("%lld\n",ans);
	for(int i=1;i<=blk+3;i++)
	{
		int l=nxt[1],r;
		for(r=nxt[1];r<=n;r++)
		{
			while(s[r]-s[l-1]>i&&l<=r)l=nxt[l];
			int ss=s[r]-s[l-1];
			if(ss==i)
			{
				int pr=pre[l]+1;
				ll mn=ss*(blk+1),mx=(r-pr+1)/ss*ss;
				ll val=(r-l+1)/ss*ss;if((r-l+1)%ss)val+=ss;
				mn=max(mn,val);
				if(mn<=mx)ans+=1ll*(mx-mn)/ss+1;
			}
		}
	}
	printf("%I64d\n",ans);
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
#define N 200002
typedef long long ll;
struct edge
{
	int to,nxxt;
}e[N];
int head[10000002],cnt=1;
char ch[N];
int n,s[N],blk,pre[N],nxt[N],a[N],b[N],tot;
bool vis[10000002];
const ll bas=1004535809,p=9999797;
inline int ask(int x)
{int u=(x+bas)%p;
	int ret=0;for(int i=head[u];i;i=e[i].nxxt)if(e[i].to==x)ret++;return ret;
}
int main()
{
	scanf("%s",ch+1);n=strlen(ch+1);blk=sqrt(n);if(blk*blk<n)blk++;
	for(int i=1;i<=n;i++)s[i]=s[i-1]+ch[i]-'0',nxt[i]=n+1;
	int la=0;
	for(int i=1;i<=n;i++)
	{
		pre[i]=la,nxt[la]=i;
		if(ch[i]=='1')la=i;
	}la=n+1;
	for(int i=n;~i;i--)
	{
		if(ch[i]=='1')la=i;
		else nxt[i]=la;
	}
	//printf("%d blk\n",blk);
	ll ans=0;
	for(int i=1;i<=blk;i++)
	{tot=0;
		for(int j=0;j<=n;j++)
		{
			int val=(j-i*s[j]+bas)%p;
			e[cnt].to=j-i*s[j],e[cnt].nxxt=head[val],head[val]=cnt++;
			if(!vis[val])
			{
				b[++tot]=j-i*s[j];vis[val]=1;
			}
		}
		for(int j=1;j<=tot;j++)
		{
			ll cj=ask(b[j]);
			ans+=1ll*cj*(cj-1)/2;
		}cnt=1;
		for(int j=1;j<=tot;j++)
		{
			int u=(b[j]+bas)%p;
			vis[u]=head[u]=0;
		}
	}
	//printf("%lld\n",ans);
	for(int i=1;i<=blk+3;i++)
	{
		int l=nxt[0],r;
		for(r=1;r<=n;r++)
		{
			while(s[r]-s[l-1]>i&&l<=r)l=nxt[l];
			int ss=s[r]-s[l-1];
			if(ss==i)
			{
				int pr=pre[l]+1;
				ll mn=ss*(blk+1),mx=(r-pr+1)/ss*ss;
				ll val=(r-l+1)/ss*ss;if((r-l+1)%ss)val+=ss;
				mn=max(mn,val);
				if(mn<=mx)ans+=1ll*(mx-mn)/ss+1;
			}
		}
	}
	printf("%I64d\n",ans);
}
//10001001


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
#define N 200002
typedef long long ll;
struct edge
{
	int to,nxxt;
}e[N];
int head[10000002],cnt=1;
char ch[N];
int n,s[N],blk,pre[N],nxt[N],a[N],b[N],tot;
bool vis[10000002];
const ll bas=1004535809,p=9999797;
inline int ask(int x){int ret=0;for(int i=head[x];i;i=e[i].nxxt)ret++;return ret;}
int main()
{
	scanf("%s",ch+1);n=strlen(ch+1);blk=sqrt(n);if(blk*blk<n)blk++;
	for(int i=1;i<=n;i++)s[i]=s[i-1]+ch[i]-'0',nxt[i]=n+1;
	int la=0;
	for(int i=1;i<=n;i++)
	{
		pre[i]=la,nxt[la]=i;
		if(ch[i]=='1')la=i;
	}la=n+1;
	for(int i=n;~i;i--)
	{
		if(ch[i]=='1')la=i;
		else nxt[i]=la;
	}
	//printf("%d blk\n",blk);
	ll ans=0;
	for(int i=1;i<=blk;i++)
	{tot=0;
		for(int j=0;j<=n;j++)
		{
			int val=(j-i*s[j]+bas)%p;
			e[cnt].to=j-i*s[j],e[cnt].nxxt=head[val],head[val]=cnt++;
			if(!vis[val])
			{
				b[++tot]=val;vis[val]=1;
			}
		}
		for(int j=1;j<=tot;j++)
		{
			ll cj=ask(b[j]);
			ans+=1ll*cj*(cj-1)/2,vis[b[j]]=head[b[j]]=0;
		}cnt=1;
	}
	//printf("%lld\n",ans);
	for(int i=1;i<=blk+3;i++)
	{
		int l=nxt[0],r;
		for(r=1;r<=n;r++)
		{
			while(s[r]-s[l-1]>i&&l<=r)l=nxt[l];
			int ss=s[r]-s[l-1];
			if(ss==i)
			{
				int pr=pre[l]+1;
				ll mn=ss*(blk+1),mx=(r-pr+1)/ss*ss;
				ll val=(r-l+1)/ss*ss;if((r-l+1)%ss)val+=ss;
				mn=max(mn,val);
				if(mn<=mx)ans+=1ll*(mx-mn)/ss+1;
			}
		}
	}
	printf("%I64d\n",ans);
}
//10001001