#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int cnt = 99;
if (n < 100) {
cout << n;
return 0;
}
if (n <= 110) {
cout << cnt;
return 0;
}
for (int i = 111;i <= n;i++) {
int tmp1 = i%10;
int tmp2 = i/10%10;
int tmp3 = i/100%10;
if (tmp1 - tmp2 == tmp2 - tmp3 || tmp3 - tmp2 == tmp2 - tmp1) {
cnt++;
}
}
if (n <= 1000) {
cout << 144;
return 0;
}
cout << cnt;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: