#include <bits/stdc++.h>
using namespace std;
vector<int> lis;
void po(int a, int b) { lis.push_back(a * 60 + b); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string a;
  cin >> a;
  for (unsigned int i = 0; i < a.size(); i++)
    if (a[i] == ':') a[i] = 32;
  string b = "";
  for (int i = 0; a[i] != 32; i++) b.insert(b.end(), a[i]);
  reverse(b.begin(), b.end());
  string z = "";
  for (unsigned int i = 3; i < a.size(); i++) z.insert(z.end(), a[i]);
  reverse(z.begin(), z.end());
  stringstream ss(a);
  int c, d, e, f;
  ss >> c;
  ss >> d;
  stringstream sp(b);
  sp >> e;
  stringstream sd(z);
  sd >> f;
  if (d == e) {
    cout << 0 << endl;
    return 0;
  }
  int mi;
  mi = c * 60 + d;
  po(0, 0);
  po(1, 10);
  po(2, 20);
  po(3, 30);
  po(4, 40);
  po(5, 50);
  po(10, 1);
  po(11, 11);
  po(12, 21);
  po(13, 31);
  po(14, 41);
  po(15, 51);
  po(20, 2);
  po(21, 12);
  po(22, 22);
  po(23, 32);
  for (unsigned i = 0; i < lis.size(); i++) {
    if (mi <= lis[i]) {
      cout << lis[i] - mi << endl;
      return 0;
    }
  }
  cout << 1440 - mi << endl;
  return 0;
}
