#include <bits/stdc++.h>
using namespace std;
bool pal(long long int h, long long int m) {
  string s = to_string(h);
  while (s.length() != 2) s = '0' + s;
  string ss = to_string(m);
  while (ss.length() != 2) ss = '0' + ss;
  s += ss;
  for (long long int i = 0; i < s.length() / 2; i++)
    if (s[i] != s[s.length() - i - 1]) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  long long int h = 0;
  for (long long int i = 0; i < 2; i++) h = h * 10 + (s[i] - '0');
  long long int m = 0;
  for (long long int i = 3; i < 5; i++) m = m * 10 + (s[i] - '0');
  long long int res = 0;
  for (long long int i = h;; i++) {
    if (i % 24 == 0) i = 0;
    for (; m < 60; m++) {
      if (pal(i, m)) {
        cout << res;
        return 0;
      }
      res++;
    }
    m = 0;
  }
}
