#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n;
const long long mod = 1e9 + 7;
const double eps = 1e-7;
char str[15];
int main() {
  cin >> str;
  int len = strlen(str);
  int hour = (str[0] - '0') * 10 + str[1] - '0';
  int minute = (str[3] - '0') * 10 + str[4] - '0';
  int re = (str[1] - '0') * 10 + str[0] - '0';
  if (re >= minute && re < 60) {
    cout << re - minute << endl;
    return 0;
  }
  int cnt = 0;
  re = 61;
  while (re >= 60) {
    hour++;
    hour %= 24;
    re = hour % 10 * 10 + hour / 10;
    cnt++;
  }
  cout << re + cnt * 60 - minute << endl;
  return 0;
}
