/*
 * @Author: LetMeFly
 * @Date: 2021-03-20 20:07:22
 * @LastEditors: LetMeFly
 * @LastEditTime: 2021-03-20 20:19:10
 */
#include <bits/stdc++.h>
using namespace std;
#define mem(a) memset(a, 0, sizeof(a))
#define dbg(x) cout << #x << " = " << x << endl
#define fi(i, l, r) for (int i = l; i < r; i++)
#define cd(a) scanf("%d", &a)
typedef long long ll;
ll ten[20];
int len(ll n)
{
    int ans = 0;
    while (n)
    {
        n /= 10;
        ans++;
    }
    return ans;
}
int main()
{
    for (int i = 0; i < 13; i++)
    {
        ten[i] = pow(10, i);
    }
    ll n;
    cin >> n;
    int l = len(n);
    if (l % 2)
    {
        int s = l / 2;
        if (!s)
            putchar('0');
        for (int i = 0; i < s; i++)
            putchar('9');
        puts("");
    }
    else
    {
        int s = l / 2;
        ll hou = n % ten[s];
        ll qian = n / ten[s];
        // printf("%lld, %lld\n", qian, hou); //**********
        if (qian > hou)
        {
            printf("%lld\n", qian - 1);
        }
        else
        {
            printf("%lld\n", qian);
        }
    }

    return 0;
}
#pragma warning (disable:4996)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

#define ll long long

#define REP(i, n) for(int i = 0; i < n; i++)
#define SET(a) ll a = 0; (void)scanf("%lld", &a);

#define NMAX 100000	//提出前に変更 100000
#define MMAX 20

//int countDifference(char*, char*, int);
bool judgeAns(char*, char*, int);

int main() {
	SET(N); SET(M);
	char S[NMAX][MMAX];
	REP(i, N)(void)scanf("%s", S[i]);
	/*
	REP(i, N) {
		(void)scanf("\n");
		REP(j, M)(void)scanf("%c", &S[i][j]);
	}
	*/
	//printf("Hello, world!");

	//int ex = countDifference(S[0], S[1], M);
	/*
	int ans = 0;
	REP(i, N) {
		for (int j = i + 1; j < N; j++) {
			int dif = countDifference(S[i], S[j], M);
			if (dif % 2 == 1)ans++;
		}
	}
	printf("%d", ans);
	*/
	/*
	int ans = 0;
	REP(i, N)for (int j = i + 1; j < N; j++)if (judgeAns(S[i], S[j], M))ans++;
	printf("%d", ans);
	*/

	ll ans = 0;
	for (int i = 1; i < N; i++)if (judgeAns(S[0], S[i], M))ans++;
	printf("%lld", ans * (N - ans));
	return 0;
}

/*
int countDifference(char* s, char* t, int m) {
	int count = 0;
	REP(i, m)if (s[i] != t[i])count++;
	return count;
}
*/

bool judgeAns(char* s, char* t, int m) {
	int count = 0;
	REP(i, m)if (s[i] != t[i])count++;
	return (count % 2);
}